![]() ![]() * Implements hook_preprocess_HOOK() for. ![]() Assuming your theme is called "mytheme" you would write the following function: /** Let's assume we wanted to add a class of my-menu to all of the menus on your site. Rebuild the cache so your changes are available (if you have drush installed, drush cr on the command line).To discover hook names, see Locating Template Files with Debugging. This should load theme-related information inside the Drupal Themer Information. To create a hook for you create mytheme_preprocess_node_article (replacing dashes with underscores). Click on the Enable Theme developer link in the Development block. To create a hook for you create mytheme_preprocess_page. Create a function such as mytheme_preprocess_HOOK where HOOK refers to the item you wish to affect. HOOK names follow twig template suggestions.Create or edit a file in your theme directory called mytheme.theme.If you want to make theme-independent markup you should add code to a custom module, where in place of mytheme.theme you have mymodule.module.įor the purposes of documentation here "mytheme" is the machine name of your theme for example "bartik" is a theme machine name. This is a good way to alter theme-specific markup. For example, if you wanted to add a class to a menu and preferred to do this at the PHP level you can. Theming Drupal 8, 9, and 10 More information Knowing how to inspect the variables available within a template file enables you to discover all of the dynamic content in a Twig file, not just that which is already being used. Just like Drupal 7, you can affect the output of certain HTML via preprocess functions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |