0

I'm using Bolt cms for my new website and I want to display an overview of entries (news items). That list must have all the entries except for the latest 5 items. I'm fairly new with it, so I'm not familiar with all the possibilities Twig has.

I can use a % for % loop to skip the latest entries. But I don't know the exact code for this. Can someone help me and explain why the used code is used?

1 Answers1

0

First, get a bunch of entries:

{% setcontent lastentries = "entries/last/10" %}

Then use a for loop to take only the last five out of ten:

{% for entry in lastentries|slice(5,9) %}

Note that slice slice starts at '0', instead of '1'.

Bopp
  • 664
  • 3
  • 5
  • Thanks Bob! This works fine. Just curious: why the extra ,9 in the code for the slice? Without it ( slice(5) ) I also get all ten entries without the first five. –  Nov 22 '14 at 12:46
  • Without the 'ending' 9, it just gets "from 5 to the end", which will also work, as you've found out. :-) – Bopp Nov 22 '14 at 18:16