i want to display a completely custom home page, not represented by a node or the default feed. for any custom url, i can do that easily using hook_menu() to define a MENU_CALLBACK item that calls my custom function to render the resulting page. but how would i specify the key for the menu item that corresponds to the home page url? i have tried using "" and "/" as the url/key, and neither works.

i know i can do this using hook_preprocess_page(), but it seems like i should be able to hook the home page using hook_menu. am i wrong?

thanks for any useful info.

Most helpful answers

Or go to Configuration > System > Site information and set any page as the home page. I am pretty sure that there is never a menu item for literally "/".

Comments

I may be misunderstanding what you are trying to do, but creating a homepage without any node or default feed is very easy in Backdrop. 

Just go here: admin/structure/layouts/manage/home and remove the "promoted content" block. Then add whatever blocks/content you want. This home layout is what you get at "/" and you don't need any specific content on it. 

I don't understand what you are trying to do with hook_menu.

 

you have not misunderstood, and the method you describe might well work for me.

what i was looking for is a way to invoke the function(s) that construct and render the content for that url directly, the way hook_menu() allows for with virtually any other url. i want that function to be called prior to any template files being processed, and i assumed (perhaps incorrectly) that anything done in the layout is being done during processing of the layout template file.

clearly i am not familiar enough with layouts and how they factor into the overall request handling logic (having come from drupal 7).

at any rate, i can accomplish exactly what i want in hook_preprocess_page(), and i guess i could do it in hook_preprocess_layout() as well.

thanks for the response!

Or go to Configuration > System > Site information and set any page as the home page. I am pretty sure that there is never a menu item for literally "/".

I am pretty sure that there is never a menu item for literally "/".

if that is true, then that is the info i was looking for, thanks.

what i have not yet tried (which i will try shortly) is this:

- set the home page setting to "/my-custom-home-page", where that url has no corresponding node/view/feed/alias.

- add a callback menu item to hook_menu() which maps that url to my function.

when i have tried something like that in the past, i got a 404. but i understand hook_menu a bit better now, i will give that a try.

thanks!