0

I can remove the "Home" tab from the main menu going to /admin/structure/menu/manage/main, but I would like to automate it so that it is done at module installation. I checked that the configuration is saved in core.menu.static_menu_link_overrides.yml, but I cannot put it in config/install since it defines pages created by core. As a matter of fact, I should set enabled=false in the already existing page standard__front_page; how can I do that at module installation?

0

Following the suggestion from @Leigh Mason and copying almost verbatim from the link he posted, I ended up implementing hook_install():

function hook_install() {
  $menu_link_manager = \Drupal::service('plugin.manager.menu.link') ;
  $front_page_link = $menu_link_manager->getDefinition('standard.front_page') ;
  $front_page_link['enabled'] = 0 ;
  $menu_link_manager->updateDefinition($menu_id, $front_page_link) ;
  $cache = \Drupal::cache('menu') ;
  $cache->deleteAll() ;
}

and the link was successfully deleted. I think that the last two lines are not really needed, I will check it at the next build from scratch...

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.