By thekid on
Hi,
In my code, I create some tabs using MENU_LOCAL_TASK.
Sometimes for some unknown reasons, the tabs disappears for some users.
I have the similar codes from other Drupal or contributed modules.
The only remedy that I can do is to truncate all cache tables and do menu_rebuild().
Can anyone help me?
Thanks.
Comments
What does your menu item code
What does your menu item code look like?
My code
Thanks for the reply. I didn't expect it to be very fast.
This is the particular item that often disappears:
You also reply on
You also reply on _mymodule_check_admin() which is called regardless of $may_cache and this may be the source of your problem.
if(_mymodule_check_admin(arg(1))) {should beif(!$may_cache && _mymodule_check_admin(arg(1))) {. You will need to clear the menu cache after the change and given _mymodule_check_admin() returns true the user should see the tab.Thank you
Thank you, nevets. It may have worked.
I found a page that is missing the Admin tab and just by refreshing the page a couple of times and without having to truncate the tables, I can see the tab now.
I think I understand the use of
$may_cachebetter.Does this mean that
mymodule_menuis actually called twice with$may_cache = trueand$may_cache = false?Is there an easy rule of thumb when an item should be listed when
$may_cache = trueand vice versa?Thanks.
Correct about hook_menu being
Correct about hook_menu being called twice (in Drupal 5).
Easy rule of thumb, if the menu item is surrounded by conditional logic it should be the case where $may_cache is false.
Thanks a lot!
Thanks a lot!