Created
May 11, 2012 14:54
-
-
Save andrewschoen/2660259 to your computer and use it in GitHub Desktop.
Revisions
-
andrewschoen created this gist
May 11, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ from menus.menu_pool import menu_pool from django import template from menus.templatetags.menu_tags import cut_after register = template.Library() @register.inclusion_tag('cms/dummy.html', takes_context=True) def show_rooted_sub_menu(context, levels=100, root_level=0, template="menu/sub_menu.html"): """ show the sub menu of the current nav-node. -levels: how many levels deep -temlplate: template used to render the navigation """ try: # If there's an exception (500), default context_processors may not be called. request = context['request'] except KeyError: return {'template': 'menu/empty.html'} nodes = menu_pool.get_nodes(request) children = [] for node in nodes: if (node.ancestor and node.level == root_level) or (node.selected and node.level == root_level): cut_after(node, levels, []) children = node.children for child in children: child.parent = None children = menu_pool.apply_modifiers(children, request, post_cut=True) context.update({'children':children, 'template':template, 'from_level':0, 'to_level':0, 'extra_inactive':0, 'extra_active':0 }) return context