Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Specify number of items of a collection to display

Started by Muut Archive 10 years ago · 1 replies · 365 views
10 years ago

Background-Info: I am building a grid that displays all categories of products on a website. The grid items consist of a background-image, the title of the category and its' first three child-categories.

Is there any way to tell a page collection definition to display only a certain number of elements? The definition is working as expected, but i only want to to show the first 3 items. Or do I have to define the limitation of displayed elements in twig? if yes, please give me a hint how this has to be made.

Thx :)

10 years ago

God ... RTFM ...

For your info, i managed it by using the twig slice filter in twig:

TWIG

{% for category in page.collection|slice(0,3) %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago