Developers

load

Loads specific types of objects and assigns them into a variable that is accessible in 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 the attributes or empty list if none match. 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.

Optional attributes:

  • limit - limits returned list length. Applies to articles and media_sets

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" limit=10 %}
<h2>{{ my_gallery.title }}</h2>
{% for article in my_articles %}
  <div>{{ article.title }}</div>
{% endfor %}