Rodrigo Souza
Rodrigo Souza

Reputation: 35

How to get spcific child page in django cms with {% show_menu_below_id %}?

My DjangoCMS has the structure:

--Page a
----Page a.1
----Page a.2
----Page a.3
----Page a.4

Using {% show_menu_below_id "Page a"%} shows this:

<ul>
   <li> Page a.1</li>
   <li> Page a.2</li>
   <li> Page a.3</li>
   <li> Page a.4</li>
</ul>

I need to show then in the navegation menu in two separeted columns, like:

<ul>
   <li> Page a.1</li>
   <li> Page a.2</li>
</ul>
<ul>
   <li> Page a.3</li>
   <li> Page a.4</li>
</ul>

How do I get just some of the childs page?

Upvotes: 0

Views: 1134

Answers (1)

petr
petr

Reputation: 2586

You can do a lot when you specify a custom HTML for the menu. The template tag would be following:

{% show_menu 0 100 100 100 "menu_top.html" %}

And in the menu_top.html, you have a variable called children available for your convenience. You can use the for loop counter to determine when to insert additional HTML and split the lists or you can use other parameters of the menu items (i.e. do they have children etc.). You can even create a menu modifier and enhance the navigation tree when custom parameters are needed.

Here is an example from the Django CMS repo:

{% load menu_tags %}

{% for child in children %}
<li class="child{% if child.selected %} selected{% endif %}{% if child.ancestor %} ancestor{% endif %}{% if child.sibling %} sibling{% endif %}{% if child.descendant %} descendant{% endif %}">
    <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
    {% if child.children %}
    <ul>
        {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
    </ul>
    {% endif %}
</li>
{% endfor %}

Upvotes: 1

Related Questions