4

Drupal のデフォルトのユーザー プロファイル ページにあるリンク タブを編集するにはどうすればよいですか? user_profile.tpl.php ファイルを作成して、プロファイル全体を最初から再構築する必要がないようにしています。これを行う簡単な方法がある場合は、むしろそれを行います。しかし、カスタム テンプレートの作成を余儀なくされた場合、プロファイルのメニュー タブを制御するにはどうすればよいでしょうか? その部分を説明するドキュメントはまだ見つかりません。

4

2 に答える 2

2

編集

ユーザープロファイルタブの一般的な変更を行いたいとは思いませんでしたが、必ずしもそれらを削除する必要はありませんでした。タブを変更する方法のいくつかの異なる例を提供するために、コードを変更しました。

編集2

user_access()メニューの再構築中にのみチェックされるため、未設定のチェックを削除しました。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配列を使用してDrupalに登録されます。このモジュールを有効にした後、キャッシュを再構築し、タブを変更する必要があります。

于 2010-08-02T21:13:23.137 に答える
1

Tab Tamerモジュールを使用して、ユーザー プロファイル ページに表示される Drupal のデフォルトのリンク タブを編集できます。

于 2014-03-25T08:23:16.480 に答える