Trying to do something quite basic but can't seem to get it right..

I'm searching through a form, and want to select entries where the value 'pax' is equal or more than the searched value.

{% set params = {
section:    'ships',
limit:      null
} %}

{# pax #}
{% if craft.request.getParam('pax') %}
  {% set pers = craft.request.getParam('pax') %}
  {% set params = params|merge({'pax' : '>= pers'}) %}
{% endif %}

Now, this doesn't seem to work. However, if I'd change the last line to:

  {% set params = params|merge({'pax' : '>= 30'}) %}

It gives me excellent results. So, what am I doing wrong here?

Much appreciated!!


You are currently passing a string '>= pers' to the array. Change this to:

'>= ' ~ pers

This "concatenates" the string '>= ' and the value of your pers variable (converted to a string).

|improve this answer|||||
  • Awesome! I had tried '>=' pers without the ~, so no succes. This works great, thanks! – Niels Oct 8 '15 at 13:24

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.