Here's my code in _nav.html. I'm trying to make certain menu items list all posts tagged with that menu item slug. It works for the first child2 forloop, but then displays the error afterwards
{% for child2 in child.nav_children %}
{% if child2.nav_children.size > 0 or child2.parent.slug == 'topics' and child2.slug != 'hot_topics' and child2.slug != 'customized_conversations' %}
<li class="drop">
<a href="{{ child2.url }}">{{ child2.name }}<i class="icon-right-open"></i></a>
<ul class="subsub">
{% if child2.parent.slug == 'topics' and child2.slug != 'hot_topics' and child2.slug != 'customized_conversations' %} <!-- Making categories list topics instead of subpages/posts -->
{% tag child2.slug with "nav_category_topic_list" %} <!-- Get all posts with tag name -->
{% else %}
{% for child2child in child2.nav_children %}
<li>
<a href="{{ child2child.url }}">{{ child2child.name }}</a>
</li>
{% endfor %}
{% endif %}
</ul>
</li>
{% else %}
<li>
<a href="{{ child2.url }}">{{ child2.name }}</a>
</li>
{% endif %}
{% endfor %}
Hey Peter, this unfortunately won’t work due to the use of a variable (child2.slug) as the target for the {% tag %} tag; you’ll need to hardcode the tag in question rather than pulling it dynamically.
Showing 3 reactions
Sign in with
Certified Developer
Certified Developer
{% for tag_slug in tag_list }
{ include ‘show_tagged_pages’ }
{ endfor %}
and then, in show_tagged_pages.html, simply:
{% tag tag_slug with ’tagged_pageintro’ %}
instead of,
{% for tag_slug in tag_list }
{ tag tag_slug with ‘tagged_page_intro’ }
{ endfor %}
which is a bit messier but at least it works!
NationBuilder employee