load
Loads specific types of objects and assigns them into a variable that is accessible in the template. Valid types of objects are:
- article
- returns first article found by attributes or no object when it cannot find any. See allowed filter attributes. NB! unpublished articles and articles under unpublished languages are returned only in editor mode and articles under password protected blog pages are returned only when user has logged in.
- articles
- returns list of articles found by attributes or empty list if none match. See allowed filter attributes.
- buy_button
- returns the first buy button matching the attributes or no object in case of no match. See allowed filter attributes.
- buy_buttons
- returns a list of buy buttons matching the attributes or an empty list in case of no matches. See allowed filter attributes.
- media_set
- returns first media set found by attributes or no object when it cannot find any. See allowed filter attributes.
- media_sets
- returns list of media sets found by the attributes or empty list if none match. See allowed filter attributes.
- product_widget
- returns the first product widget matching the attributes or no object in case of no match.
- product_widgets
- returns a list of product widgets matching the attributes or an empty list in case of not matches.
Optional attributes:
- limit
- limits returned list length. Applies to
articles
andmedia_sets
- limits returned list length. Applies to
- tag
- limits returned list by article tag (value can be string or array). Applies to
article
andarticles
- limits returned list by article tag (value can be string or array). Applies to
Examples
Find mediaset by title and assign it to variable named "my_gallery".
{% load media_set to "my_gallery" q.media_set.title="Foobar" %}
<h2>{{ my_gallery.title }}</h2>
{% for photo in my_gallery.photos %}
<img src="{{photo.medium_thumbnail_url}}">
{% endfor %}
Find articles by title and page and assign it to variable named "my_articles".
{% load articles to "my_articles" q.page.id=page.id q.article.title.$starts="Event" s="article.created_at.$desc,article.id.$desc" limit=10 %}
{% for article in my_articles %}
<div>{{ article.title }}</div>
{% endfor %}
Filter by single article tag.
{% load articles to "my_articles" q.page.id=page.id tag="my tag" s="article.created_at.$desc,article.id.$desc" limit=10 %}
{% for article in my_articles %}
<div>{{ article.title }}</div>
{% endfor %}
Filter by single article tags.
{% assign my_tags = 'tag1,tag2' | split: ',' %}
{% load articles to "my_articles" q.page.id=page.id tag=my_tags limit=10 %}
{% for article in my_articles %}
<div>{{ article.title }}</div>
{% endfor %}