0👍
✅
You need to send down some information about what node you’re in, and then it’s a simple if
statement.
Regarding how to send down the node information universally, there are a couple ways to do this in Django, and none of them are perfect. My preferred method is context processors: http://docs.djangoproject.com/en/1.3/ref/templates/api/#writing-your-own-context-processors
0👍
{% recursetree nodes %}
<li>
<a href="/category/{{ node.get_absolute_url }}">{{ node.name }}</a>
{% if node.name == category.name %}
<ul>
{{ children }}
</ul>
{% endif %}
<li>
{% endrecursetree %}
0👍
You can try this:
{% recursetree nodes %}
#check if the node is a child node
{% if node.is_child_node %}
<a href="{{ node.get_absolute_url }}" >{{ node.name }}</a>
{% endif %}
#check if a root node is the current category
{% if node.is_root_node and node.name == category.name %}
{{ children }}
{% endif %}
{% endrecursetree %}
Source:stackexchange.com