You are here

function template_preprocess_uikit_accordion in UIkit Components 8.3

Prepares variables for UIkit Accordion templates.

Default template: uikit-accordion.html.twig.

Parameters

$variables: An associative array containing:

  • element: An associative array containing:

    • #items: An array of items to be displayed in the accordion. Each item must contain the title and content properties.
    • #component_options: An array containing the component options to apply to the accordion. These must be in the form of "option: value" in order to work correctly.

See also

\Drupal\uikit_components\Element\UIkitAccordion

https://getuikit.com/docs/accordion#component-options

Related topics

File

includes/preprocess.inc, line 37
Set up variables to be placed within the template (.html.twig) files.

Code

function template_preprocess_uikit_accordion(&$variables) {
  $element = $variables['element'];

  // Set the items variable, if items is not empty.
  if (!empty($element['#items'])) {
    $variables['items'] = $element['#items'];
  }

  // Set the attributes variable.
  $variables['attributes'] = $element['#attributes'];
}