问题
I've added a number of new tabs to the user page, using Views (as a page with menu tab settings etc.). What I now want to do is remove them if the viewed user is the current, logged in user.
Prior to adding some user filtering, my first problem is that I just can't seem to modify these tabs at all. I know the general procedure is to use HOOK_MENU_ALTER and (for example):
$items['user/%user/view']['type'] = MENU_CALLBACK;
This works fine for the original tabs, but not for tabs added with Views, e.g. for an 'Articles' tab:
$items['user/%user/articles']['type'] = MENU_CALLBACK;
Are tabs added by Views handled differently to 'normal' tabs?
Cheers, James
回答1:
First of all you won't be able to hide them dynamically by making them MENU_CALLBACK. What you should do is change the access callback to a function where you would check for the current user.
As for why you can't find the tabs, check if:
- There isn't a menu entry with %views_arg instead of %user
- That your module's weight (in the system table) is bigger than views' weight. Since views uses the same hook it's possible that your module gets called before views.
回答2:
I think views is adding all it's stuff in hook_menu_alter(). To change it, you need to give your module a higher weight in the {system} table than views has.
来源:https://stackoverflow.com/questions/5143663/drupal-modify-tabs-added-to-user-page-by-views