Drupal - 修改按视图添加到用户页面的选项卡
我使用视图(作为带有菜单选项卡设置等的页面)向用户页面添加了许多新选项卡。我现在想要做的是,如果查看的用户是当前登录的用户,则删除它们。
在添加一些用户过滤之前,我的第一个问题是我似乎根本无法修改这些选项卡。我知道一般过程是使用 HOOK_MENU_ALTER 和(例如):
$items['user/%user/view']['type'] = MENU_CALLBACK;
这对于原始选项卡来说效果很好,但不适用于使用视图添加的选项卡,例如“文章”选项卡:
$items['user/%user/articles']['type'] = MENU_CALLBACK;
由视图添加的选项卡处理方式与“正常”不同选项卡?
干杯, 詹姆斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您将无法通过将它们设置为 MENU_CALLBACK 来动态隐藏它们。您应该做的是将访问回调更改为您将在其中检查当前用户的函数。
至于为什么找不到选项卡,请检查是否:
%views_arg 而不是 %user
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:
%views_arg instead of %user
我认为视图正在将所有内容添加到 hook_menu_alter() 中。要更改它,您需要在 {system} 表中为模块赋予比视图更高的权重。
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.