1

So I'm not sure this is possible with the entries search param but I'm trying to return entries where a field (rich text) has fewer than 200 characters. This is obviously horribly wrong but something like...

{% set params = {
    limit: 3, order: 'RAND()', search: 'quote:|length < 200', section: 'quotes'
} %}

Any help much appreciated!

1

You should be able to do this by adding an additional Preparse field to the entry.

Set the value of the field (call it quoteLength) to this:

{{ entry.quote | length }}

Then search for all entries with a quote less than 200 characters using this search:

{% set params = {
    limit: 3, order: 'RAND()', quoteLength: '< 200', section: 'quotes'
} %}
1
  • Thanks Steve. That's a decent option but I think since these particular entries are old (from an import) and new ones will be shorter, I'll just discard the old ones based on date or entry.type.
    – Ian Ebden
    Mar 3 '17 at 12:52
1

I'm not 100% sure what you are trying to achieve but If its because all the others would be to big for whatever you're building. You could use Hacksaw to fit all your text.

https://github.com/ryanshrum/hacksaw

1
  • Yeah that's the problem I have. Some entries are too long for this particular use. Don't really want to truncate. Thanks though.
    – Ian Ebden
    Mar 3 '17 at 11:34

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.