Drupal標準では、ノード編集権を持つユーザーがノードページを表示した際、メインコンテンツとタイトルの間あたりにノード編集用のタブが表示されます。
これはこれで便利ですが、どうも見た目が未承認ユーザーで表示する場合といくらか異なり、気分が悪いです。
これをViewsやBlockのようにコンテキストメニュー(ネジアイコン)に置き換えるには?
ノードページの編集タブをコンテキストメニューにしたい
OTHER FAQ
カテゴリ | Core Ver. | 関連モジュール | タイトル |
---|---|---|---|
コンテンツの管理 | 7.15 | Pagenation | 一つの長いページをBookなどのように連続して読ませることはできますか? |
コンテンツの管理 | 8.9.x | Dialog Modal Canvas | drupal 8 の標準機能のダイアログ/ポップアップを表示する方法 |
コンテンツの管理 | 8.4x | Action | カスタムアクションを作成する方法 |
コンテンツの管理 | 6.x | Views Flag Calendar | 空き室予約のような仕組みは実現できますか? |
コンテンツの管理 | 8.5.x | Field File | コンテンツのフィールドの表示について |
コンテンツの管理 | 8.4x | Entity | EntityをPropertyで探す(クエリする)方法 |
コンテンツの管理 | 7.15 | Content Access | 簡単に閲覧制限を行うには? |
コンテンツの管理 | 7,51 | Views Data Export | Views Data ExportでCSVデータが欠けてしまう |
コンテンツの管理 | 7.50 | Administration menu | 標準のユーザー管理ページ |
コンテンツの管理 | 7.38 | Block Views node | ノードページの編集タブをコンテキストメニューにしたい |
コンテンツの管理 | 7.16 | PHP | 好きなところにノードを埋め込みたい |
サイトの構築 | 7.27 | Context block | ページ別、カテゴリ別等でブロックの表示有無を簡単にするには |
サイトの構築 | 7.38 | deployment | 冗長構成におけるアップロードおよび時間指定公開について |
サイトの構築 | 7.19 | Plesk | Pleskでdrupal7(プライベートファイルシステム)を使う場合の注意点 |
サイトの構築 | 7.59 | Drupal.ajax | drupal 7 で Uncaught TypeError: Drupal.ajax is undefined となったときの対応方法 |
サイトの構築 | 7.23 | Conditional fields | ノード編集フォームを動的にしたい |
サイトの構築 | 7.26 | Field Views | フォーム選択肢(プルダウンやチェックボックス、ラジオボタン)のカスタマイズ方法 |
サイトの構築 | 7.38 | Content Template | ページテンプレートが反映されません。 |
サイトの構築 | 7.22 | Views Devel | Viewsの設定ページが変に? |
サイトの構築 | 7.50 | Module Missing Message Fixer | モジュールをアンインストールしたらエラーがでるようになった |
コメント
hook_preprocess_page() と hook
パーマリンク Submitted by actbrain on 2015/07/01 16:00.
hook_preprocess_page() と hook_preprocess_node() を使うことで可能になります。
/**
* Implement hook_preproces_page().
*/
function モジュール名_preprocess_page(&$variables) {
if (ノード編集タブをネジアイコンにしたい) {
if (user_access('access contextual links')) {
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$variables['tabs'] = array('#secondary' => array()); // 標準の編集タブを削除
}
}
}
}
/**
* Imprement hook_preprocess_node().
*/
function モジュール名_preprocess_node(&$variables) {
if (ノード編集タブをネジアイコンにしたい) {
if (user_access('access contextual links')) {
$menu_local_tasks = menu_local_tasks();
if (isset($menu_local_tasks['tabs']['output'])) {
$variables['content']['#prefix'] = '<div class="contextual-links-region">'.
'<div class="contextual-links-wrapper">'.
'<ul class="contextual-links">'.
render($menu_local_tasks['tabs']['output']).
'</ul>'.
'</div>';
$variables['content']['#suffix'] = '</div>';
}
}
}
}
ページ