1

I'm processing some feeds using craft.app.feeds.getFeedItems() and it works if I pass the limit as a hard coded number like this:

{% set items = craft.app.feeds.getFeedItems(entry.rssURL, '5') %}
<ul>
    {% for item in items %}
      <li><a href="{{ item.permalink }}">{{ item.title }}</a></li>
    {% endfor %} 
</ul>

However if I change '5' to a field handle I get errors. where entry.feedLimit is a number such as 3 or 5

{% set items = craft.app.feeds.getFeedItems(entry.rssURL, entry.feedLimit) %}
<ul>
    {% for item in items %}
      <li><a href="{{ item.permalink }}">{{ item.title }}</a></li>
    {% endfor %} 
</ul>

The errors I get is:

TypeError Argument 2 passed to craft\feeds\Feeds::getFeedItems() must be of the type integer or null, object given, called in /path/to/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1619

This code was previously working on Craft 2, but after the update it is now broken. I've temporarily hard coded the limit in, but that's not ideal.

  • What type of field is feedLimit? – Brad Bell Dec 16 '18 at 1:04
  • it's a select and I solved it by changing code to entry.feedLimit.value – CreateSean Dec 16 '18 at 1:13
1

Solution is simple, the field type is a select so I need to change

entry.feedLimit

to

entry.feedLimit.value

And then it works

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.