Drupal - Modify tabs added to user page by Views

半腔热情 提交于 2019-12-12 02:53:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!