Created
November 8, 2018 18:56
-
-
Save ryanirelan/df47bbce06d97c7fc3d306290c4f46c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Using the example code from the docs #} | |
{% set searchQuery = craft.app.request.getParam('q') %} | |
{% set entries = craft.entries() | |
.search(searchQuery) | |
.orderBy('score') | |
.all() %} | |
{# You can do something like this where you just output the Section name #} | |
{% for entry in entries %} | |
<h4>{{ entry.section }}</h4> | |
<li><a href="{{ entry.url }}">{{ entry.title }}</a></li> | |
{% endfor %} | |
{# If you want to check for a certain section, you can do: #} | |
{% for entry in entries %} | |
{% if entry.section.handle == 'blog' %}<span class="ico blog"></span>{% endif %} | |
<li><a href="{{ entry.url }}">{{ entry.title }}</a></li> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment