Hot answers tagged

2

I understood the variable passed by hook_theme are static Yes, you can consider default values defined in hook_theme as static, they are set when you install the module. To help developers clearing the cache also clears most things which are installed by modules, so that you don't need to re-install the module all the time, but this has nothing to do with ...


1

a default value seems to be needed in hook_theme */ function amu_social_icon_theme($existing, $type, $theme, $path) { $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); return [ 'amu_social_icon_block' => [ 'variables' => [ 'icons' => null, 'lang' => $language, ], ], ]; } as ...


1

Maybe your problem come from function theme printer_friendly. If your define this funtion, you have to provide variables when define. If this function from contribute module you can use hook_preprocess_printer_friendly to add more variables before render in twig template.


1

First problem to get current user roles use this \Drupal::currentUser()->getRoles(); Second problem: $variables['node']->type is an array so use $variables['node']->bundle() to get type instead: The third drupal_add_js not supported anymore in Drupal 8 use library and attached so try something like the following /** * Implements ...


1

Easiest solution is to use the Metatag module, indeed. For a full code solution, I'd recommend you to have a look at core/themes/classy/templates/layout/html.html.twig file (which is the default html template used by Drupal if your theme does not override it) for clues concerning template variables. The variable you want to alter is head_title which, as ...


1

You need to use the THEMENAME.theme file to store this in.


Only top voted, non community-wiki answers of a minimum length are eligible