修改通过视图添加到用户页面的选项卡

修改通过视图添加到用户页面的选项卡

本文介绍了Drupal - 修改通过视图添加到用户页面的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在用户页面中添加了一些新的选项卡,使用视图(作为具有菜单选项卡设置的页面等)。我现在想做的是删除它们,如果被查看的用户是当前登录的用户。

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.

在添加一些用户过滤之前,我的第一个问题是我只是似乎根本无法修改这些选项卡。我知道一般的过程是使用HOOK_MENU_ALTER和(例如):

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?

干杯,
James

Cheers,James

推荐答案

首先你将无法隐藏它们通过使其成为MENU_CALLBACK而动态。您应该做的是将访问回调更改为要检查当前用户的功能。

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而不是%user

  • 您的模块的重量(在系统表中)大于视图的重量。由于视图使用相同的钩子,您的模块可能在视图之前被调用。

这篇关于Drupal - 修改通过视图添加到用户页面的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:52