1

I have imported entries, each with 2 fields that comprise a range of numbers... numberStart and numberEnd. e.g. 3000 - 3006, in some instances both are the same number e.g. 8001 - 8001 The user will be inputting a single number and I need to return the single entry where the inputted number lands between (or is equal to) the start and (or) end number.

This is what I have so far...

{% set userInputtedNumber = 3000 %} 

{% set entries = craft.entries({
    section: 'section',
    numberStart: '>=' ~ userInputtedNumber,
    numberEnd: '<=' ~ userInputtedNumber,
}) %}

This just returns nothing as the operators clash.

Any ideas will be welcomed!

0

Think you've just got a logic error in your Twig code. This should work:

{% set userInputtedNumber = 3000 %}

{% set entries = craft.entries({
    section: 'channel',
    numStart: '<=' ~ userInputtedNumber,
    numEnd: '>=' ~ userInputtedNumber,
}) %}
  • Urg I knew it was going to be something simple! I copied this logic from some php and didn't make the needed adjustments. Thank you! – MikeeBee Sep 27 '17 at 4:06

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.