Dynamic node names
How to create a few nodes in a template with auto-generated names (e.g. for column design)
{% blocknode 'page/column-1.md' %}
## Luke
{% endblocknode %}
{% blocknode 'page/column-2.md' %}
## Leia
{% endblocknode %}
{% blocknode 'page/column-3.md' %}
## Han
{% endblocknode %}
I want do it like this
{% with forloop.counter|format:"page/column-%s.md" as uri %}
{% blocknode uri %}
## Luke
{% endblocknode %}
{% endwith %}
But got and error
Unknown plugin "None" or improperly configured pipeline for node "i18n://ru-ru@".
Due to underlaying cache performance, dynamic nodes URI's can not be used.
All URI's gets picked up by content-io when the template is parsed, and then hydrated against cache (i.e. memcached) in bulk when the first node gets rendered. This is to reduce latency and increase page speed.
What you can do is to prepare your wanted nodes in the view instead, and add them to the context. By doing this, the same performance is kept because the node objects from content-io is lazy. Unfortunately you wont be able to "click" on the nodes to edit since the template tag is not used, and you need to choose the nodes from the djedi admin panel.
Example (dummy code, not tested ;-)
# views.py
import cio
def foobar(request):
column_nodes = [cio.get('page/column-{}.md'.format(i)) for i in range(1, 4)]
return render(.....{'column_nodes': column_nodes})
<!-- template -->
<body>
{% for node in column_nodes %}
{{ node }}
{% endfor %}
</body>
We have a fragment of another extra template tag (not released yet) that could handle a node object instead of the URI to get the inline click/edit feature together with node objects from context.