Diosney
Diosney

Reputation: 10580

How to get the depth level at a any given level in the template

Setup:

Issue:

How to know at any given recursion level the depth level at which currently I am?

Example:

This is the HTML:

<ul>
    <li>
        0

        <ul>
            <li>1</li>
            <li>1</li>
        </ul>
    </li>

    <li>0</li>
</ul>

0,1 are the children's depth level that I want to get at any given time.

Upvotes: 2

Views: 395

Answers (1)

spac3_monkey
spac3_monkey

Reputation: 130

You can use the template variable node.level and it will give you the indentation level.

You can read more about it at:

http://django-mptt.readthedocs.org/en/latest/technical_details.html?highlight=level#level

Upvotes: 3

Related Questions