Drupal標準では、ノード編集権を持つユーザーがノードページを表示した際、メインコンテンツとタイトルの間あたりにノード編集用のタブが表示されます。
これはこれで便利ですが、どうも見た目が未承認ユーザーで表示する場合といくらか異なり、気分が悪いです。
これをViewsやBlockのようにコンテキストメニュー(ネジアイコン)に置き換えるには?
ノードページの編集タブをコンテキストメニューにしたい
OTHER FAQ
カテゴリ | Core Ver. | 関連モジュール | タイトル |
---|---|---|---|
コンテンツの管理 | 8.5.x | Field File | コンテンツのフィールドの表示について |
コンテンツの管理 | 8.9.x | 写真の変更を行いたい | |
コンテンツの管理 | 8.4x | Entity | EntityをPropertyで探す(クエリする)方法 |
コンテンツの管理 | 7.15 | Content Access | 簡単に閲覧制限を行うには? |
コンテンツの管理 | 7,51 | Views Data Export | Views Data ExportでCSVデータが欠けてしまう |
コンテンツの管理 | 8.9.x | Dialog Modal Canvas | drupal 8 の標準機能のダイアログ/ポップアップを表示する方法 |
コンテンツの管理 | 7.16 | PHP | 好きなところにノードを埋め込みたい |
コンテンツの管理 | 7.15 | Views Bulk Operation | 標準のコンテンツ編集/ユーザ一覧ページが物足りません |
コンテンツの管理 | 7.15 | Pagenation | 一つの長いページをBookなどのように連続して読ませることはできますか? |
コンテンツの管理 | 8.4x | Action | カスタムアクションを作成する方法 |
コンテンツの作成 | 7.26 | Form Ajax | 入力フォームで#ajax使用時、#default_valueを書き換えても反映しない |
コンテンツの作成 | 8.4x | node | node保存前に色々やる方法 |
コンテンツの作成 | 8.4x | json | jQueryにjsonで渡す方法 |
コンテンツの作成 | 7.15 | Darty Form | 編集ページでの操作ミス |
コンテンツの作成 | 8.9.x | Display sweet, Views, Twig Tweak, Views field formatter | テーマに頼らず コンテンツのフィールドとしてViewsを埋め込み表示する方法 |
コンテンツの作成 | 7.15 | Form API Validation | フォームの入力内容を細かくチェックしたい |
コンテンツの作成 | 8.4x | archiver | zipファイル圧縮・解凍する方法 |
コンテンツの作成 | 6.x | Insert Block | ブロックの内容を本文中に表示するには? |
コンテンツの作成 | 7.34 | Entityreference prepopulate | 新規ノード作成時のリファレンス方法 |
コンテンツの作成 | 7.38 | Webform | Webformでテーブル形式にしたい |
コメント
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>';
}
}
}
}
ページ