Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By sacarney on
I would like to display the content type of a search result. My search results are producing Articles, Pages, Book pages, and Forum posts.
The documentation in search-result.html.twig seems to show {{ info_split.type }} should do that, but it isn't showing anything.
I have tried <pre>{{ dump(info_split) }}
. This dumps 'user', 'date', and 'comment' as expected, but not 'type'.
Here is the code from search-result.html.twig:
{{ title_prefix }}
<h3{{ title_attributes.addClass('h5') }}>
<a href="{{ url }}">{{ title }}</a>
</h3>
{{ title_suffix }}
<p>{{ info_split.type }}</p>
{% if snippet %}
<p{{ content_attributes }}>{{ snippet }}</p>
{% endif %}
{% if info %}
<p>{{ info_split.date }}</p>
{% endif %}
<pre>
{{ dump(info_split) }}
</pre>