Theme Tags
Storyblok's cloud rendering service allows you to focus on the template without worrying about the API handling at all. We've encompassed the available functions in easy to use Tags.
Get Story / Content Entry
Encompasses the Story Content Delivery API.
Single
by Slug
{% set variable from story id:'global' %} <!-- id at this point is equal to a content entries slug. -->
{{ variable.name }} <!-- Will output the content entries name -->
By uuid
{% set variable from story id:'c6b4d6fc-6e93-4c31-8bb7-04b04eeac0b7', find_by:'uuid' %} <!-- id at this point is equal to a content entries uuid. -->
{{ variable.name }} <!-- Will output the variable content entries name -->
Collection
Access a content entry by a folders slug
{% set posts from stories starts_with:'posts', per_page: 3, is_startpage: false %}
{% for post in posts.data %}
{{ post.name }} <!-- Will output the name of the post -->
{% endfor %}
As you can see from the examples above, you've the possibility to easily create an overview page without having to worry about the API request handling. You can filter and sort as necessary.
<!-- Sets the stories beginning with the slug 'products' and filter by options array -->
{% set stories from stories starts_with:'products', per_page:per_page, filter_by:'{"options":["red"]}' %}
Get Data Source Entries
Capsules the Datasource Content Delivery API
<!-- Retrieves the first 10 entries from the datasource 'labels' -->
{% set entries from datasource_entries datasource:'labels', per_page:'10', page: 1 %}
{{ entries | json }}
Get Links
Capsules the Links Content Delivery API
{% set navitems from links %}
{% for navitem in navitems.data.links %}
{{ navitem[1].name }}
{% endfor %}
Get Tree
Capsules the Links Content Delivery API and transfers it into a traversable array.
<!-- Gets content entries and folders as tree (ex. for generating menus) -->
{% set navitems from tree %}
{% for navitem in navitems %}
{{ navitem[1].item.name }}
<ul class="sidenav">
{% for i in navitem[1].children %}
{% if i[1].children|length > 0 %}
<li>
{{ i[1].item.name }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
Flow
With the flow tag you can return a 404 response header. Following example shows how to render the "not found" page when a variable is blank.
{% if product_results == blank %}
{% flow show_404 %}
{% endif %}