Contents
What is the base theme hook in Drupal?
For theme suggestions, instead of the array key being the base theme hook, the key is a theme suggestion name with the format ‘base_hook_name__sub_hook_name’. For render elements, the key is the machine name of the render element. The array values are themselves arrays containing information about the theme hook and its implementation.
What are the keys of the theme hook?
$theme : The actual name of theme, module, etc. that is being being processed. $path : The directory path of the theme or module, so that it doesn’t need to be looked up. array An associative array of information about theme implementations. The keys on the outer array are known as “theme hooks”.
What is the template name for Drupal theme?
For example, if a module registers the ‘search_result’ theme hook, ‘search-result’ will be assigned as its template name. function: (deprecated in Drupal 8.0.x, will be removed in Drupal 9.0.x) If specified, this will be the function name to invoke for this implementation.
How to create custom theme suggestions in Drupal 8?
Twig allows us to create very easy-to-understand templates very quickly, and the Theme Debug setting allows us to see what template suggestions and hooks are used for the site elements. Additionally, we’re able to create our own custom theme suggestions using hook_theme_suggestions_HOOK_alter ().
What does Hook theme suggestions hook Alter do?
The hook_theme_suggestions_HOOK_alter is a pre-process function that allows us to easily produce custom template suggestions based on an existing hook. For instance, if we wanted to alter the theme suggestions for all of our Pages, then we could use silo_theme_suggestions_page_alter ().
Where to find the suggestion template in Drupal?
The default is to use it for nodes but a suggestion is made for rendering them inside block regions. This suggestion is used by default and the template file is located at “modules/poll/poll-results–block.tpl.php”. See poll-results.tpl.php in the Drupal API documentation for more information.
Is there theme debug mode for Drupal 8?
For Drupal 8 follows Template naming convention URL. As of Drupal 7.33, Drupal core has a theme debug mode that can be enabled and disabled via the theme_debug variable and is very helpful when working with template suggestions. Custom suggestions beyond the ones listed below can be created.
What are the elements of a render array?
The following elements may be part of each information array: variables: Only used for #theme in render array: an array of variables, where the array keys are the names of the variables, and the array values are the default values if they are not given in the render array.
What are the menu items in Drupal API?
Each menu item has a key corresponding to the Drupal path being registered. The corresponding array value is an associative array that may contain the following key-value pairs: “title”: Required. The untranslated title of the menu item. “title callback”: Function to generate the title; defaults to t ().
How to make tab the default tab in Drupal?
To do that, first create one menu item of type MENU_NORMAL_ITEM , with your chosen path, such as ‘foo’. Then duplicate that menu item, using a subdirectory path, such as ‘foo/tab1’, and changing the type to MENU_DEFAULT_LOCAL_TASK to make it the default tab for the group.