1.20.x layout.api.php | hook_layout_style_info() |
Provides information on rendering styles that can be used by layouts.
This hook provides a list of styles that can be used both by regions and individual blocks. A style can modify the output of a layout if needed for specialized presentation.
Return value
array: An info array keyed by a unique machine name for that style. Possible keys include:
- title: The translated title of the style.
- description: The translated description of the style.
- block theme: Optional. If this style modifies the display of blocks, specify the theme function or template key that would be passed into the theme function.
- class: Optional. The name of a class which contains any advanced methods to configure and save settings for this display style. If not specified, the default class of LayoutStyle will be used. Each class must also be registered in hook_autoload_info().
- file: Optional. The name of the file the implementation resides in. This file path is NOT the path to the class. Class paths and loading is done through hook_autoload_info().
- path: Optional. Override the path to the file to be used. Ordinarily theme functions are located in a file in the module path (for example: mymodule/mymodule.theme.inc) and template files are located in a subdirectory named templates (for example: mymodule/templates/), but if your file will not be in the default location, include it here. This path should be relative to the Backdrop root directory.
- template: If specified, this theme implementation is a template, and this is the template file name without an extension. Do not include the extension .tpl.php; it will be added automatically. If 'path' is specified, then the template should be located in this path.
- hook theme: Optional. If specified, additional information to be merged into hook_theme() on behalf of this style. This may be necessary if the values provided for "block theme" have not already been registered.
See also
Related topics
File
- modules/
layout/ layout.api.php, line 159 - Describe hooks provided by the Layout module.
Code
function hook_layout_style_info() {
$info['custom_style'] = array(
'title' => t('A new style'),
'description' => t('An advanced style with settings.'),
// The theme key for rendering an individual block.
'block theme' => 'mymodule_block',
// Provide a class name if this style has settings. The class should extend
// the LayoutStyle class.
'class' => 'MyModuleLayoutStyle',
// Override the path to the file to be used.
'path' => 'templates/subdir',
// Name of template file (with or without path).
'template' => 'templates/my-filename',
);
return $info;
}