/** * @return array */ function yourmodule_token_info() { return [ 'types' => [ 'your-token-name' => [ 'name' => t('Settings'), 'description' => t('...'), ], ], 'tokens' => [ 'your-token-name' => [ 'your_token_name-1' => [ 'name' => t('...'), 'description' => t('...'), ], 'your_token_name-2' => [ 'name' => t('...'), 'description' => t('...'), ], ], ], ]; } /** * @param $type * @param $tokens * @param array $data * @param array $options * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadat * * @return array */ function yourmodule_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadat) { $replacements = []; $sanitize = !empty($options['sanitize']); switch ($type) { case 'your-token-name': $replacements['[your_token_name-1]'] = '...'; $replacements['[your_token_name-2]'] = '...'; break; } return $replacements; }
カスタムモジュールからtokenを提供する方法(drupal8版)
OTHER FAQ
カテゴリ | Core Ver. | 関連モジュール | タイトル |
---|---|---|---|
コンテンツの作成 | 8.9.x | CKEditor | CKEditor編集中の見た目をフロントと全く同様にする方法 |
コンテンツの作成 | 7.38 | CKEditor | 突然GoogleMap内の経路がずれてしまった |
コンテンツの作成 | 7.34 | CCK | ノード入力フォームへパラメータを渡す |
Calendar | 7.34 | Calendar | CalendarモジュールとGoogleカレンダーを同期するには |
コンテンツの管理 | 7.38 | Block Views node | ノードページの編集タブをコンテキストメニューにしたい |
テーマ | 8.3x | Block Cache Theme | 管理ページから作成したカスタムブロックを非キャッシュ化する方法 |
コンテンツの作成 | 7.15 | Automatic_Nodetitles Automatic_Entity_Label | ノード投稿フォームにタイトル入力フォームを表示しない方法 |
コンテンツの作成 | 8.4x | archiver | zipファイル圧縮・解凍する方法 |
サイト情報 | 8.9.x | api | Drupal::request() メモ |
フォーム | 8.9.x | api | GET/POSTされた情報を得る方法 |
SESSION | 8.9.x | api | $_SESION操作のAPI |
コンテンツの作成 | 7.34 | ajax | 標準のajaxフォーム(複数値:値の数=無制限)の制御l方法 |
コンテンツの管理 | 7.50 | Administration menu | 標準のユーザー管理ページ |
コンテンツの管理 | 8.4x | Action | カスタムアクションを作成する方法 |
テーマ | 8.7.x | Bartikのtwigについて | |
ブロック | 7.23 | 伸縮するfieldsetブロックを追加したい | |
テーマ | 8.9.x | スマホに向いたテーマについて | |
jQuery Revolution | 7.50 | jQuery Revolutionのリンクがスマホで機能しない | |
PCRE | 7.50 | preg_match()がおかしい | |
コンテンツの管理 | 8.9.x | 写真の変更を行いたい |