3

When performing a search on the front-end, is it possible to have two different behaviors, depending on the number of results?

  • With more than one result, show the normal "results" page.
  • With only a single result, automatically redirect to that entry page.
2
  • I've reworded the question based on what I believe you are after... Please feel free to roll it back (or edit further) if I am mistaken!
    – Lindsey D
    Oct 27 '15 at 19:07
  • Ahhh... thanks for the edit / translation @Lindsey.
    – carlcs
    Oct 27 '15 at 19:27
2

Redirecting to the first result is simple...

{% if results|length == 1 %}
    {% redirect results[0].url %}
{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.