0

We have a small D7 site. We want to deactivate a main menu item. On dev server I was able to deactivate it in /admin/structure/menu/manage/main-menu

I believe The menu is stored in the DB, right. Also in a config file? So you only need to deploy those two things and it is done.

Is that correct? If not, what are the steps to deploy a main menu change?

  • Log in to your live site and do the same. Menu items are entities same as nodes, taxonomy terms, users. So you need to do that from the UI or write a custom module update hook to do that programmatically (then deploy the module and trigger database updates). – leymannx Nov 13 at 14:22
  • Look into using the Features module. – No Sssweat Nov 13 at 14:24
  • Update hook is the proper way handling these types of things. See jDrupal's answer below – Mariano Crivello Nov 13 at 20:03
2

Menu items are saved in the DB, therefore you must update them using update hooks.

Something like this should work:

function MODULE_NAME_update_N() {
  $menu_link_id = 1;
  $menu_link = menu_link_load($menu_link_id);
  $menu_link['hidden'] = 0;
  menu_link_save($menu_link);
}
  • 1
    Make sure you follow the constructs described here: drupal.org/docs/7/creating-custom-modules/howtos/… – Mariano Crivello Nov 13 at 20:02
  • Would they actually have same ids across environments? – anoopjohn Nov 14 at 2:11
  • @anoopjohn assuming you pulled the latest live DB to your local/dev before making the change, yes. – No Sssweat Nov 14 at 6:18
  • Thanks for the reply. I was wondering if that would always be the case even if you start with the same database copy. – anoopjohn Nov 14 at 6:42
  • Yes I think so, normally you create content on prod and then use the prod DB on dev so that way the IDs would be the same. – Jdrupal Nov 14 at 7:05
1

Menu items are sore in the database.

You are still able to export the menu using a contrib module.

For Drupal 7

You can achieve that by using Menu Export/Import contrib module.

For Drupal 8

You can achieve that by using Menu Import and Export. The module will give you the ability to exports the menu entity as config YAML and will be imported on subsequent instances.

  • Unfortunately that module is only available for Drupal 8, OP is asking for a Drupal 7 solution. – Jdrupal Nov 14 at 9:22
  • I update the answer for D7, I used to do that with feature module, but I don't remember if that was feature module or feature extra module – Ziftman Nov 14 at 9:36
0

You can use Features Module.

  1. Create another feature for menus. enter image description here
  2. Push your new module to your server.
  3. Enabled it in the new server.

    drush en your_feature

  4. Revert your feature

    drush fr your_feature

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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