function template_preprocess_uikit_article in UIkit Components 8.3
Prepares variables for UIkit Article templates.
Default template: uikit-article.html.twig.
Parameters
$variables: An associative array containing:
- element: An associative array containing:
- #title (optional): The title of the article.
- #meta (optional): The metadata of the article, such as the author and created date.
- #lead (optional): The leading paragraph of the article.
- #content: The content of the article.
See also
\Drupal\uikit_components\Element\UIkitArticle
https://getuikit.com/docs/article
Related topics
File
- includes/
preprocess.inc, line 103 - Set up variables to be placed within the template (.html.twig) files.
Code
function template_preprocess_uikit_article(&$variables) {
$element = $variables['element'];
// Set the title, meta, lead and content variables, if they are not empty.
if (!empty($element['#title'])) {
$variables['title'] = $element['#title'];
}
if (!empty($element['#meta'])) {
$variables['meta'] = $element['#meta'];
}
if (!empty($element['#lead'])) {
$variables['lead'] = $element['#lead'];
}
if (!empty($element['#content'])) {
$variables['content'] = $element['#content'];
}
// Set the attributes for the article outer element.
$variables['attributes'] = $element['#attributes'];
}