function template_preprocess_filter_tips

Same name and namespace in other branches
  1. 8.9.x core/modules/filter/filter.module \template_preprocess_filter_tips()
  2. 10 core/modules/filter/filter.module \template_preprocess_filter_tips()
  3. 11.x core/modules/filter/filter.module \template_preprocess_filter_tips()

Prepares variables for filter tips templates.

Default template: filter-tips.html.twig.

Parameters

array $variables: An associative array containing:

  • tips: An array containing descriptions and a CSS ID in the form of 'module-name/filter-id' (only used when $long is TRUE) for each filter in one or more text formats. Example:
array(
    'Full HTML' => array(
        0 => array(
            'tip' => 'Web page addresses and email addresses turn into links automatically.',
            'id' => 'filter/2',
        ),
    ),
);
  • long: (optional) Whether the passed-in filter tips contain extended explanations, i.e. intended to be output on the path 'filter/tips' (TRUE), or are in a short format, i.e. suitable to be displayed below a form element. Defaults to FALSE.

File

core/modules/filter/filter.module, line 414

Code

function template_preprocess_filter_tips(&$variables) {
    $tips = $variables['tips'];
    foreach ($variables['tips'] as $name => $tiplist) {
        foreach ($tiplist as $tip_key => $tip) {
            $tiplist[$tip_key]['attributes'] = new Attribute();
        }
        $variables['tips'][$name] = [
            'attributes' => new Attribute(),
            'name' => $name,
            'list' => $tiplist,
        ];
    }
    $variables['multiple'] = count($tips) > 1;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.