[英]How do I edit link tabs found on the default user profile page in drupal?
How do I edit link tabs found on the default user profile page in drupal? 如何编辑drupal中默认用户配置文件页面上的链接选项卡? I'm trying to avoid having to create a user_profile.tpl.php file and rebuild the entire profile from scratch.
我试图避免必须创建user_profile.tpl.php文件并从头开始重建整个配置文件。 If there's an easier way to do this, I'd rather do that.
如果有更简单的方法,我宁愿那样做。 But, if I'm forced to create a custom template, how do I control the menu tabs for the profile?
但是,如果我被迫创建自定义模板,如何控制配置文件的菜单选项卡? I haven't found any documentation that explains that part yet.
我还没有找到任何解释该部分的文档。
Edit 编辑
I didn't catch that you wanted to do generic modification of the user profile tabs, not necessarily removing them. 我没有意识到你想要对用户配置文件选项卡进行通用修改,而不是删除它们。 I've modified my code to provide a few different examples of how you can modify the tabs.
我修改了我的代码,提供了一些如何修改标签的不同示例。
Edit 2 编辑2
Removed the user_access()
check on the unset as it would only be checked during the menu rebuild. 删除了
user_access()
设置的user_access()
检查,因为它只会在菜单重建期间进行检查。 Added access callback
example instead. 添加了
access callback
示例。
You can do this in a custom module with hook_menu_alter()
and unset()
: 您可以使用
hook_menu_alter()
和unset()
在自定义模块中执行此操作:
function mymodule_menu_alter(&$items) {
// If you have the Devel module installed, uncomment to retrieve list
// of registered menu items to figure out what to unset.
// kpr($items);
// Change the name of the Edit tab
$items['user/%user_category/edit']['title'] = t('Awesome edit!');
// Disable the user edit tab, but don't disable the page if you go navigate
// directly to it
// @see http://api.drupal.org/api/function/hook_menu/6 for other types
$items['user/%user_category/edit']['type'] = MENU_CALLBACK;
// Only allow people with administer site configuration permissions to
// access the user edit and user edit account tabs.
$items['user/%user_category/edit']['access callback'] = 'user_access';
$items['user/%user_category/edit']['access arguments'] = array('administer site configuration');
$items['user/%user_category/edit/account']['access callback'] = 'user_access';
$items['user/%user_category/edit/account']['access arguments'] = array('administer site configuration');
// Completely disable the user edit tab, even if you go directly to it
// This affects all users, including user 1.
unset($items['user/%user_category/edit']);
unset($items['user/%user_category/edit/account']);
}
Each menu item is registered with Drupal using the $items
array. 使用
$items
数组向Drupal注册每个菜单项。 After enabling this module, rebuild the cache and the tabs should be modified. 启用此模块后,重建缓存并应修改选项卡。
您可以使用Tab Tamer模块编辑出现在用户配置文件页面中的Drupal默认链接选项卡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.