Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
When you say "I want to create the primary menu programmatically" do you mean you want to add items to the primary menu or control the look of the primary menu?
Using hook_menu , it is possible to create a menu or menu item and using 'type' attribute , one can set the type of that menu item e.g MENU_NORMAL_ITEM or MENU_CALLBACK
so at the same way, using hook_menu , is it possible to create a menu item which adds in primary menu
e.g my primary menu name is : BookOrder so can i create a menu item which adds in BookOrder using
hook_menu.
The following will work though it depends on how core has implement certain things, as part of defining a menu item you could do
'pid' => variable_get('menu_primary_menu', 0),
which will set the parent of the given menu item. If there is no primary menu it is assigned to the navigation menu instead (since pid is 0). Also if you plan to contribute the module, it is not good practice to assign menu items to the primary menu by default.
Comments
Do you mean add items or control the look
When you say "I want to create the primary menu programmatically" do you mean you want to add items to the primary menu or control the look of the primary menu?
Add Items to primary menu
Hello,
Using hook_menu , it is possible to create a menu or menu item and using 'type' attribute , one can set the type of that menu item e.g MENU_NORMAL_ITEM or MENU_CALLBACK
so at the same way, using hook_menu , is it possible to create a menu item which adds in primary menu
e.g my primary menu name is : BookOrder so can i create a menu item which adds in BookOrder using
hook_menu.
do you have any idea ?
Thank you.
This will work
The following will work though it depends on how core has implement certain things, as part of defining a menu item you could do
which will set the parent of the given menu item. If there is no primary menu it is assigned to the navigation menu instead (since pid is 0). Also if you plan to contribute the module, it is not good practice to assign menu items to the primary menu by default.
Working...
yes , this is working.
thanx for your great help.