Skip to content

Instantly share code, notes, and snippets.

@joshcartme
Created December 1, 2012 00:46
Show Gist options
  • Save joshcartme/4179810 to your computer and use it in GitHub Desktop.
Save joshcartme/4179810 to your computer and use it in GitHub Desktop.
page_menu which takes a site_id and renders a menu from that site
import os
from mezzanine.pages.templatetags.pages_tags import page_menu
from mezzanine import template
from mezzanine.utils.sites import current_site_id
register = template.Library()
@register.render_tag
def page_menu_for_site(context, token):
"""
Creates a page menu grabbing pages from the given site_id rather than the
current_site which is default.
"""
parts = token.split_contents()
site_id = parts[-1]
old_site_id = current_site_id()
print old_site_id
del parts[-1]
token.contents = ''
for part in parts:
token.contents += '%s ' % part
context['request'].site_id = site_id
menu = page_menu(context, token)
retval = menu.render(context)
context['request'].site_id = old_site_id
return retval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment