代码之家  ›  专栏  ›  技术社区  ›  Dylan West

如何编辑drupal中默认用户配置文件页面上的链接选项卡?

  •  4
  • Dylan West  · 技术社区  · 14 年前

    2 回复  |  直到 14 年前
        1
  •  2
  •   user113292 user113292    14 年前

    编辑

    我不知道你想对用户配置文件标签做一般性的修改,而不一定要删除它们。我已经修改了我的代码,提供了几个不同的示例,说明如何修改选项卡。

    编辑2

    删除了 user_access() 选中unset,因为它只会在菜单重建期间被选中。补充 access callback


    您可以在自定义模块中使用 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']);
    }
    

    每个菜单项都使用 $items 数组。启用此模块后,应重新生成缓存并修改选项卡。

        2
  •  1
  •   Nadeem Khan    11 年前

    Tab Tamer 用于编辑出现在用户配置文件页面中的Drupal默认链接选项卡的模块。