How to show in django cms breadcrumbs full path? -


need advice - how show in breadcrumbs whole path article or page? i've got code:

{% ance in ancestors %}    <li>        {% if not forloop.last %}        <a href="{{ ance.get_absolute_url }}">{{ ance.get_menu_title }}</a>     {% else %}       <span class="active">{{ ance.get_menu_title }}</span>     {% endif %}    </li> {% endfor %} 

but shows "home" , current page. how modify show whole path in breadcrumbs?

i've found in file menu_tags.py code calls ancestors. @ least there class showbreadcrumbs:

    class showbreadcrumb(inclusiontag):     """     shows breadcrumb node has same url current request      - start level: after level should breadcrumb start? 0=home     - template: template used render breadcrumb     """     name = 'show_breadcrumb'     template = 'menu/dummy.html'      options = options(         argument('start_level', default=0, required=false),         argument('template', default='menu/breadcrumb.html', required=false),         argument('only_visible', default=true, required=false),     )      def get_context(self, context, start_level, template, only_visible):         try:             # if there's exception (500), default context_processors may not called.             request = context['request']         except keyerror:             return {'template': 'cms/content.html'}         if not (isinstance(start_level, int) or start_level.isdigit()):             only_visible = template             template = start_level             start_level = 0         try:             only_visible = bool(int(only_visible))         except:             only_visible = bool(only_visible)         ancestors = []         nodes = menu_pool.get_nodes(request, breadcrumb=true)          # find home         home = none         root_url = unquote(reverse("pages-root"))         home = next((node node in nodes if node.get_absolute_url() == root_url), none)          # find selected         selected = none         selected = next((node node in nodes if node.selected), none)          if selected , selected != home:             node = selected             while node:                 if node.visible or not only_visible:                     ancestors.append(node)                 node = node.parent         if not ancestors or (ancestors , ancestors[-1] != home) , home:             ancestors.append(home)         ancestors.reverse()         if len(ancestors) >= start_level:             ancestors = ancestors[start_level:]         else:             ancestors = []         context['ancestors'] = ancestors         context['template'] = template         return context   register.tag(showbreadcrumb)   def _raw_language_marker(language, lang_code):     return language   def _native_language_marker(language, lang_code):     force_language(lang_code):         return force_text(ugettext(language))   def _current_language_marker(language, lang_code):     return force_text(ugettext(language))   def _short_language_marker(language, lang_code):     return lang_code   markers = {     'raw': _raw_language_marker,     'native': _native_language_marker,     'current': _current_language_marker,     'short': _short_language_marker, } 

that exact same breadcrumb template use achieve this, long page structure similar to;

home   child     grandchild   child     grandchild 

you need load template menu tags like; {% show_breadcrumb 0 "partials/breadcrumb.html" 0 %}

the docs on menu tags here

don't forget, if have pages hidden menus, won't display in breadcrumbs either because they're created menu tags using page tree.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -