Searching in Twig

Related Links


You can search entries in Twig just like you normally would using the model. Because of the similarity between the EntryCriteria and the QueryBuilder it wraps it feels very familiar.

Basic Usage

To get started searching entries simply start a query and use the search function:

{% verbatim %}{% set results = entries('posts', 'categories').search('news').get() %}{% endverbatim %}

Paginating Results

Similarly you can paginate results in Twig the same way:

{% verbatim %}{% set results = entries('posts', 'categories').search('news').paginate(15) %}

{% foreach result in results %}
{% endforeach %}

{{ results.render()|raw }} {# or alternatively use links() #}{% endverbatim %}