All pastes #95879 Raw Edit

django nav bar

public python v1 · immutable
#95879 ·published 2006-07-22 12:01 UTC
rendered paste body
from django import templateimport reregister = template.Library()def makelinks(pageTitle, pageUrl):    # Assume direct mapping between the flatpages <title> and the url hierarchy    pageTitles = [p.strip() for p in pageTitle.split("|")]    pageUrls = pageUrl.strip("/").split("/")        outputText = []    c = 1        try:        for title in pageTitles:            outputText.append(' &raquo; <a href="/%s">%s</a>' % ('/'.join(pageUrls[0:c]), title.lower()))            c += 1    except:        pass    return ''.join(outputText)    register.filter(makelinks)