Since the Layout system was introduced to Backdrop in 1.0.0, there has been an ongoing effort to disambiguate between two separate Layout concepts:
- Layout configurations (the saved configuration, usually to a JSON file)
-
Layout templates (the collection of a
.tpl.php
,.css
, and.info
file)
Initially, both of these concepts were both simply called "layouts", which led to confusion as to which concept applied.
In Backdrop 1.30.0, hook_layout_info()
, which allows modules to create additional Layout templates, was renamed to hook_layout_template_info()
to clarify that the hook applies to templates, not to configuration.
Prior to Backdrop 1.30.0:
function mymodule_layout_info() {
$layout_templates['my_layout_template'] = array(
'title' => t('A custom layout template'),
'path' => 'layouts/my-layout-template',
'regions' => array(
'header' => t('Header'),
'content' => t('Content'),
'sidebar' => t('Sidebar'),
'footer' => t('Footer'),
),
// Optional information that populates using defaults.
'preview' => 'preview.png',
'stylesheets' => array('all' => array('one-column.css')),
'template' => 'layout--my-layout-template',
// Specify a file containing preprocess functions if needed.
'file' => 'my_layout_template.php',
);
return $layout_templates;
}
Backdrop 1.30.0 and higher:
(This is exactly the same except _template
has been added to the function name:
function mymodule_layout_template_info() {
$layout_templates['my_layout_template'] = array(
'title' => t('A custom layout template'),
'path' => 'layouts/my-layout-template',
'regions' => array(
'header' => t('Header'),
'content' => t('Content'),
'sidebar' => t('Sidebar'),
'footer' => t('Footer'),
),
// Optional information that populates using defaults.
'preview' => 'preview.png',
'stylesheets' => array('all' => array('one-column.css')),
'template' => 'layout--my-layout-template',
// Specify a file containing preprocess functions if needed.
'file' => 'my_layout_template.php',
);
return $layout_templates;
}
Note that the old hook_layout_info()
(and hook_layout_info_alter()
) continue to work but they are deprecated. They will be removed in Backdrop 2.x.