search-results.html.twig

Default theme implementation for displaying search results.

This template collects each invocation of theme_search_result(). This and the child template are dependent to one another sharing the markup for definition lists.

Note that modules may implement their own search type and theme function completely bypassing this template.

Available variables:

  • search_results: All results as it is rendered through search-result.html.twig.
  • module: The machine-readable name of the module (tab) being searched, such as 'node' or 'user'.
  • pager: The pager next/prev links to display, if any.
  • help: HTML for help text to display when no results are found.

See also

template_preprocess()

template_preprocess_search_results()

1 theme call to search-results.html.twig
search_data in drupal/core/modules/search/search.module
Performs a search by calling hook_search_execute().

File

drupal/core/modules/search/templates/search-results.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for displaying search results.
  5. *
  6. * This template collects each invocation of theme_search_result(). This and
  7. * the child template are dependent to one another sharing the markup for
  8. * definition lists.
  9. *
  10. * Note that modules may implement their own search type and theme function
  11. * completely bypassing this template.
  12. *
  13. * Available variables:
  14. * - search_results: All results as it is rendered through
  15. * search-result.html.twig.
  16. * - module: The machine-readable name of the module (tab) being searched, such
  17. * as 'node' or 'user'.
  18. * - pager: The pager next/prev links to display, if any.
  19. * - help: HTML for help text to display when no results are found.
  20. *
  21. * @see template_preprocess()
  22. * @see template_preprocess_search_results()
  23. *
  24. * @ingroup themeable
  25. */
  26. #}
  27. {% if search_results %}
  28. <h2>{{ 'Search results'|t }}</h2>
  29. <ol class="search-results {{ module }}-results">
  30. {{ search_results }}
  31. </ol>
  32. {{ pager }}
  33. {% else %}
  34. <h2>{{ 'Your search yielded no results'|t }}</h2>
  35. {{ help }}
  36. {% endif %}

Related topics