Skip to content
Snippets Groups Projects
Commit 94be34d2 authored by catch's avatar catch
Browse files

Issue #3345789 by andy-blum: Improve documentation of hook_theme_suggestions_HOOK()

(cherry picked from commit 18b08a83)
parent 16059bcb
No related branches found
No related tags found
5 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment
......@@ -610,7 +610,26 @@ function hook_preprocess_HOOK(&$variables) {
* must otherwise make sure that the hook implementation is available at
* any given time.
*
* @todo Add @code sample.
* Suggestions must begin with the value of HOOK, followed by two underscores to be discoverable.
*
* In the following example, we provide suggestions to
* node templates based bundle, id, and view mode.
*
* @code
* function node_theme_suggestions_node(array $variables) {
* $suggestions = [];
* $node = $variables['elements']['#node'];
* $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
* $suggestions[] = 'node__' . $sanitized_view_mode;
* $suggestions[] = 'node__' . $node->bundle();
* $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
* $suggestions[] = 'node__' . $node->id();
* $suggestions[] = 'node__' . $node->id() . '__' . $sanitized_view_mode;
*
* return $suggestions;
* }
*
* @endcode
*
* @param array $variables
* An array of variables passed to the theme hook. Note that this hook is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment