cms
cms copied to clipboard
[4.x]: Cannot use "tag" Twig tag inside "nav" Twig tag
What happened?
This code will throw error (note the "tag" Twig tag placed inside "nav").
{% set entries = craft.entries().section('pages').all() %}
<ul id="nav">
{% nav entry in entries %}
{% tag 'div' with {
class: 'something',
} %}
some content
{% endtag %}
<li>
<a href="{{ entry.url }}">{{ entry.title }}</a>
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
</li>
{% endnav %}
</ul>
Craft CMS version
4.4.13
PHP version
8.1
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Hi, thanks for reaching out. I’ve just run it on Craft 4.4.13, and the template renders as expected without errors. What error are you seeing with this code?