Voog.com

elementscontext

Executes block of template where list of requested elements is available. Additional element query parameters can be supplied with tag attributes. For example if your elements have properties "name" and "awarded_product" and you want to only show awarded elements with name "Cowbell":

{% elementscontext awarded_product="1" name="Cowbell" %}
  {% for element in elements %}
    <a href="{{ element.url }}">{{ element.title }}</a>
  {% endfor %}
{% endelementscontext %}

Boolean values are defined by 0 (false) and 1 (true).
It also supports Voog API filtering syntax over fields supported in Elements API. Example:

{% elementscontext q.element.values.category.$in="Books" s="element.values.date.$asc" %}
  {% for element in elements %}
    <a href="{{ element.url }}">{{ element.title }}</a>
  {% endfor %}
{% endelementscontext %}

The element query parameter can also accept regular expressions. Example of all products that have property name starting with "electric-":

{% elementscontext name="/^electric-/" %}
  ...
{% endelementscontext %}

Optional fixed parameters

  • edicy_page_path_prefix
    • Display only elements associated with page whose path starts with given path (includes child pages): 
      {% elementscontext edicy_page_path_prefix="products/blenders" %}
        {% for element in elements %}
          <p><a href="{{ element.url }}">{{ element.title }}</a></p>
        {% endfor %}
      {% endelementscontext %}
  • edicy_page_path: 
    • Display only elements associated with page whose path is given path (does not include child pages): 
      {% elementscontext edicy_page_path="products/blenders " %}
        {% for element in elements %}
          <p><a href="{{ element.url }}">{{ element.title }}</a></p>
        {% endfor %}
      {% endelementscontext %}
  • edicy_page_path_var: 
    • Display only elements associated with page whose path is given with variable:
      {% assign productlist="products/blenders" %}
      {% elementscontext edicy_page_path_var="productlist" %}
        {% for element in elements %}
          <p><a href="{{ element.url }}">{{ element.title }}</a></p>
        {% endfor %}
      {% endelementscontext %}

  • edicy_model: 
    • Name of object model such as "Product"
  • edicy_all_languages: 
    • Search across all languages. By default elements only in current language are searched.
      {% elementscontext edicy_all_languages="true" edicy_model="Product" %}
        {% for element in elements %}
          <p><a href="{{ element.url }}">{{ element.title }}</a></p>
        {% endfor %}
      {% endelementscontext %}