Задать вопрос

Тел: +7 965 3737 888

522

Просмотров

1

Ответов

Breadcrumbs for flatpages

<p>Custom template filter to generate a breadcrumb trail for a flatpage.  Say you have a series of flatpages with URLs like /trunk/branch/leaf/ etc.  This filter looks at the URL of a given flatpage, figures out which of the leftwards text chunks correspond to other flatpages, and generates a string of anchored HTML.</p>
<p>Usage:</p>
{% load make_breadcrumb_trail %}

{{ flatpage.url|crumbs:flatpage.title }}

Вопрос полезен? Да0/Нет0
file_5144.py(827.0б)
None

Ответы (1):

Ответbradmontgomery:14.06.2009
Ответ полезен? Да0/Нет0

Great Snippet that works perfectly. Just a heads-up for anyone else wanting to use this: Don't forget that the app in which this template is installed must be included in INSTALLED_APPS in settings.py.

For example, I have a utils app that contains code used project-wide. I installed this snippet into myproject.utils.templatetags.make_breadcrumb_trail but the {% load make_breadcrumb_trail %} failed until I added 'myproject.utils' to my INSTALLED_APPS.

Thanks!