0

I have a series of sites that use the same theme. What I'm looking to achieve is to manage the main menu (or a standard menu) via a module instead.

Reasoning: Most of these sites will have the menu the exact same. If I need to change something, I would do it in the module. I could put it in the theme, but I'd rather the site admins not have control over appearance or to change the theme, have the ability to add to the menu if that have a small item that needs to be placed there, or the ability to simply not show the entire menu and manage their own.

I've tried the following, but every time the cache is cleared, a new item is added. If I change something, it just adds a new item and leaves the old one.

function something_mainmenu_menu() {

    $items['external'] = array(
        'title' => 'External Item',
        'link_path' => 'http://www.whatever.com',
        'type' => MENU_NORMAL_ITEM,
        'menu_name' => 'main-menu'
    );
}

Is this possible in Drupal as a module, or should I just put it in the theme and do a case based on the URL?

1 Answer 1

0

You can stop roles from editing menus via the permissions page. That should lock that down.

Then to manage the menus on all your sites you could use Menu Export/Import module (https://drupal.org/project/menu_import), which plays nicely with Drush to allow you to export/import entire menus. You could maintain your "master" menu in a text file in json format and then periodically push it out to all sites at once using Drush aliases or a simple shell script. Because Drush uses uid 1 I think you should be able to do whatever you need regardless of how you set your roles' permissions via the UI.

1
  • I would want them to be able to add to the menu but not remove items that the module would place there. menu_import doesn't fit exactly as I want would to replace just the items I have and not what a site admin would create. Commented Feb 19, 2014 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.