1

I'm trying to limit the results to 5, but its returning all of the results instead. I am using the below code:

{% set options = {
  cache : false,
  query : {
    limit : 5
  }
} %}

{% set timeline = craft.placid.request('projectsLatestTrending', options ) %}

<ol>
{% for tweet in timeline.data %}
  <li>{{ tweet.name }}</li>
{% endfor %}
</ol>

Thanks in advance for any help.

  • This would have to be accomplished through the API your accessing. Placid creates the gateway to the API. The API would need to limit the results returned. – aran Aug 15 '17 at 14:31
1

That function was added in Feb 2016, see the Github issue page. This is the code:

{% set events = craft.placid.request('EventsFeed').limit(5) %}

{% for event in events.data %}
  {{ event.title }}
{% endfor %}

Note the use of the .data part, this was added in the 1.7.112 version. More details here

|improve this answer|||||
1

Not a true answer, but a work around:

{% for tweet in timeline.data %}
    {% if loop.index <= 5 %}
        ...
    {% endif %}
{% endfor %}
|improve this answer|||||
  • Matt, I used an alternative method before reading this. So thanks for your efforts. – Mark Aug 15 '17 at 18:10
1

I managed to solve this using the slice filter. Short hand shown below.

Thanks for your input Matt Wilcox.

{% for tweet in timeline.data[0:5] %}

    ...

{% endfor %}
|improve this answer|||||

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.