1

This works:

            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: '>=' ~ pluginResults.latmin
            }) %}

But I need to do this:

            {% set entries = craft.entries({
                section: 'listing',
                listinglatitudenumber: 'and', '>=' ~ pluginResults.latmin, '<=' ~ pluginResults.latmax
            }) %}

And I cannot for the life of me figure out the correct syntax for this.

I have been trying many different combos for the 'and' statement based on other answers I have seen in the Craft Stack Exchange but have not been successful. I have not been able to find any docs on this type of query.

Any help much appreciated :)

1

You need to separate your criterias with commas

listinglatitudenumber: 'and, ' ~  '>=' ~ pluginResults.latmin ~ ', <=' ~ pluginResults.latmin, 
6
  • Thanks Robin once again for your help :) With the above syntax I get: Internal Server Error A hash value must be followed by a comma. Unexpected token "string" of value ", <=" ("punctuation" expected with value ","). And I am trying to understand exactly what you mean, and trying to resolve the error, but not successful - could you explain further?
    – ironfish
    Apr 22 '18 at 19:44
  • Of course you need to place a last comma since you are inside an object. Please read this craftcms.stackexchange.com/a/25774/5557 you can either separate your values via comma or you use an array from the beginning Apr 22 '18 at 19:56
  • Thank you I will look at the examples and try to get it working :)
    – ironfish
    Apr 22 '18 at 20:08
  • Let me know if you need further help. You simply need to convert PHP string separators . with twig ~ Apr 22 '18 at 20:09
  • Thank you Robin again for your time and effort on this. :)
    – ironfish
    Apr 22 '18 at 20:26
0

As per: Query entries between two values I found that enclosing the query string that I had with [ ] to make it a sub-array, works:

        {% set entries = craft.entries({
            section: 'listing',
            listinglatitudenumber: ['and', '>=' ~ pluginResults.latmin, '<=' ~ pluginResults.latmax]
        }) %}

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.