La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
manipulating array data returned by 'blog_recent_posts'
Résolue
I'm using `blog_recent_posts` but need to break up the data returned for display in different parts of the page. How can I use the Hubl `pop` function to remove the first element of the returned list of posts? Right now it removes the entire object.
The goal is to show 9 unique items "below the fold", instead of repeating ones already displayed above.
manipulating array data returned by 'blog_recent_posts'
Résolue
You could loop twice, the first time returning only the first item, the second time returning all but the first. Either {% unless loop.first %} for everything but the first item or {% loop.index > 1 and loop.index <= 10 %} for the next 9 after the first.
{% set rec_posts = blog_recent_posts('default') %}
{% for rec_post in rec_posts %}
{% if loop.first %}
<div class="post-title">{{ rec_post.name }}</div>
{% endif %}
{% endfor %}
...
{% for rec_post in rec_posts %}
{% if loop.index > 1 and loop.index <= 10 %} // to return 9 posts but not the the first
<div class="post-title">{{ rec_post.name }}</div>
{% endif %}
{% endfor %}
manipulating array data returned by 'blog_recent_posts'
Résolue
You could loop twice, the first time returning only the first item, the second time returning all but the first. Either {% unless loop.first %} for everything but the first item or {% loop.index > 1 and loop.index <= 10 %} for the next 9 after the first.
{% set rec_posts = blog_recent_posts('default') %}
{% for rec_post in rec_posts %}
{% if loop.first %}
<div class="post-title">{{ rec_post.name }}</div>
{% endif %}
{% endfor %}
...
{% for rec_post in rec_posts %}
{% if loop.index > 1 and loop.index <= 10 %} // to return 9 posts but not the the first
<div class="post-title">{{ rec_post.name }}</div>
{% endif %}
{% endfor %}