Wrong way to overwrite a menu
KiamLaLuno - August 7, 2008 - 04:11
| Project: | EveryBlog |
| Version: | 6.x-1.3-beta1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
In Drupal 6, the right way to redefine a menu of another module is to implement hook_menu_alter().

#1
What are you revering to? What menu irme am I overwriting incorrectly? More specific information would be helpful. Thanks for taking the time to post though.
Regards,
Ntroutman
#2
In
everyblog.module, the functioneveryblog_menu()contains the following definition for a menu item:<?php$blogs = array();
$items['blog/%'] = array(
'page callback' => 'everyblog_page',
'page arguments' => array(1),
'access callback' => 'everyblog_page_user_access',
'access arguments' => array(1),
'type' => MENU_CALLBACK,
'file' => 'everyblog.pages.inc',
);
?>
That menu item is already defined from
blog.module, thereforeeveryblog.modulemust implementhook_menu_alter()to alter such menu.I hope this helps to understand the issue I am talking of.
Regards,
Kiam
#3
Except that I'm not overwriting an existing menu since EveryBlog is incompatible with the core Blog module and expects it to me disabled. Without the core Blog module there is no menu item to overwrite. At least that is how I understand things to work. I'll look into more carefully later. Thanks for the post.
Regards,
NTroutman
#4
That is not stated in the project page. I was thinking the module was just an extension for
blog.modulewhich then could co-exist with it.If the module requires the core module to be disabled, then it should check that at runtime, and report an error in such case (the checking can be done in the implementation of
hook_requirements()).Until
blog.modulehas not been disabled,everyblog.moduleis re-defining an already existing menu.#5
Thanks for the info. I didn't know about the hook_requirements. I'll make the change to the project page and add the needed code. Thanks again
#6
I usually put a link to the documentation page, but this time I forgot to do it.
As the documentation for the hook states, the checking can be done when the module is being installed, or when the module is being executed; in the first case, if the hook implementation returns an error code, the installation of the module gets stopped.
#7
Thanks for the link. I'm working on making the fix right now, beta2 should be out later today.
Regards,
NTroutman