Drupal - 修改按视图添加到用户页面的选项卡

发布于 2024-10-19 20:23:55 字数 409 浏览 1 评论 0原文

我使用视图(作为带有菜单选项卡设置等的页面)向用户页面添加了许多新选项卡。我现在想要做的是,如果查看的用户是当前登录的用户,则删除它们。

在添加一些用户过滤之前,我的第一个问题是我似乎根本无法修改这些选项卡。我知道一般过程是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栀梦 2024-10-26 20:23:55

首先,您将无法通过将它们设置为 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:

  • 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.
倒数 2024-10-26 20:23:55

我认为视图正在将所有内容添加到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文