OK, so I have a weird thing to do, I’d appreciate any help. When you go to the Drupal admin panel and click Structure, you get a menu which contains Blocks, Content types, Menus and so on.
Is there a way I can programatically build one of those menus based on the path? For example if I have my module named test and all sub-actions of my module are located at www.drupalsite.com/admin/test/action_name, can I build my menu with all the /test/action_name there exist in the current module?
I know there’s the option of hard-coding the menu, but I want to avoid it if possible.
It’s hard to be that descriptive without some more information but you’d just need to implement
hook_menu()and loop through your list of actions, creating a menu item for each. Every time the menu is rebuilt your menu hook will be called and the current list of actions will be built as menu links. Something like this:After you call your custom code to create one of these actions, be sure to call
menu_rebuild()so your hook runs and the new action is added to menu.