Handling Content List Items¶
Listing Content List Items¶
Note
Content List can store many different content types (articles, events, packages).
Content List¶
Usage:
1 2 3 4 5 6 7 | <ul>
{% gimme contentList with { contentListName: "List1" } %}
<li>{{ contentList.name }}</li> <!-- Content list name -->
<li>{{ contentList.description }}</li> <!-- Content list description -->
<li>{{ contentList.type }}</li> <!-- Content list type) -->
{% endgimme %}
</ul>
|
Parameters:
1 | {% gimme contentList with { contentListId: 1 } %} - select list by it's id.
|
1 | {% gimme contentList with { contentListName: "List Name" } %} - select list by it's name.
|
Content List Items¶
Usage:
1 2 3 4 5 6 7 | <ul>
{% gimmelist item from contentListItems with { contentListName: "List1" } %}
<li>{{ item.content.title }}</li> <!-- Article title -->
<li>{{ item.position }}</li> <!-- Item position in list -->
<li>{{ item.sticky ? "pinned" : "not pinned" }}</li> <!-- Checks if item is sticky (positioned on top of list) -->
{% endgimmelist %}
</ul>
|
or
1 2 3 4 5 6 7 8 9 10 11 | {% gimme contentList with { contentListName: "List1"} %}
{% cache 'top-articles' {gen: contentList} %}
<ul>
{% gimmelist item from contentListItems with { contentList: contentList } %}
<li>{{ item.content.title }}</li> <!-- Article title -->
<li>{{ item.position }}</li> <!-- Item position in list -->
<li>{{ item.sticky ? "pinned" : "not pinned" }}</li> <!-- Checks if item is sticky (positioned on top of list) -->
{% endgimmelist %}
</ul>
{% endcache %}
{% endgimme %}
|
Note
Passing previously fetched contentList (for cache key generation needs) is good for performance.
Parameters:
1 | {% gimmelist item from contentListItems with { contentListId: 1 } %} - select list by it's Id.
|
1 | {% gimmelist item from contentListItems with { contentListId: 1, sticky: true } %} - filter by sticky value.
|
1 | {% gimmelist item from contentListItems with { contentListId: 1, sticky: true } without {content: [1]} %} - exclude article with id 1 (in case of articles as items).
|