URL based breadcrumbs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def breadcrumbs(url):
    home = ['<li>you are here : <a href="/" title="Breadcrumb link to the homepage.">home</a> &raquo;</li>',]
    links = url.strip('/').split('/')
    bread = []
    for link in links:
        if not link == '':
            bread.append(link)
            this_url = "/".join(bread)
            if not link == links[len(links)-1]:
                this_link = '<li><a href="/%s/" title="Breadcrumb link to %s.">%s</a> &raquo;</li>' % (this_url, link, link)
            else:
                this_link = '<li>%s</li>' % link
            home.append(this_link)
    bcrumb = "".join(home)
    return mark_safe(bcrumb)

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.