Skip to content

Instantly share code, notes, and snippets.

@enagorny
Created May 15, 2012 08:17
Show Gist options
  • Save enagorny/2699983 to your computer and use it in GitHub Desktop.
Save enagorny/2699983 to your computer and use it in GitHub Desktop.
{% load menu_tags sekizai_tags %}
{% for child in children %}
<li class="{% if child.selected %}selected{% endif %}{% if child.ancestor %}ancestor{% endif %}{% if child.sibling %}sibling{% endif %}{% if child.descendant %}descendant{% endif %}">
<span class="menu_item">
{% if child.tpl == "no_page.html" %}
{{ child.get_menu_title }}
{% else %}
<a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
{% endif %}
</span>
<ul>
{% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
</ul>
</li>
{% endfor %}
from menus.base import Modifier
from menus.menu_pool import menu_pool
from cms.models import Page
class JustMenu(Modifier):
"""
Menu modifier that add to node template name of the node page
used to make some page in the menu, just menu items with no links.
"""
post_cut = False
def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
tpls = dict(Page.objects.filter(id__in=[x.id for x in nodes]).values_list('id', 'template'))
for node in nodes:
node.tpl = tpls[node.id]
return nodes
menu_pool.register_modifier(JustMenu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment