Commit 18cc89f1 authored by alexpott's avatar alexpott

Issue #2495419 by Cottser: Move the 'search-results' class from the render...

Issue #2495419 by Cottser: Move the 'search-results' class from the render array and into a Classy template
parent c21e0999
......@@ -1774,7 +1774,7 @@ function drupal_common_theme() {
'variables' => array('status' => MARK_NEW),
),
'item_list' => array(
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL),
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL, 'context' => array()),
),
'feed_icon' => array(
'variables' => array('url' => NULL, 'title' => NULL),
......
......@@ -117,15 +117,12 @@ public function view(Request $request, SearchPageInterface $entity) {
'#markup' => '<h3>' . $this->t('Your search yielded no results.') . '</h3>',
),
'#list_type' => 'ol',
'#attributes' => array(
'class' => array(
'search-results',
$plugin->getPluginId() . '-results',
),
),
'#cache' => array(
'tags' => $entity->getCacheTags(),
),
'#context' => array(
'plugin' => $plugin->getPluginId(),
),
);
// If this plugin uses a search index, then also add the cache tag tracking
......
{% extends "item-list.html.twig" %}
{#
/**
* @file
* Theme override for an item list of search results.
*
* Available variables:
* - items: A list of items. Each item contains:
* - attributes: HTML attributes to be applied to each list item.
* - value: The content of the list element.
* - title: The title of the list.
* - list_type: The tag for list element ("ul" or "ol").
* - attributes: HTML attributes to be applied to the list.
* - empty: A message to display when there are no items. Allowed value is a
* string or render array.
* - context: An list of contextual data associated with the list. For search
* results, the following data is set:
* - plugin: The search plugin ID, for example "node_search".
*
* @see template_preprocess_item_list()
*/
#}
{%
set classes = [
'search-results',
context.plugin ~ '-results',
]
%}
{% set attributes = attributes.addClass(classes) %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment