Skip to content

Commit

Permalink
Allow hiding last page siblings in breadcrumbs (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnglkv authored May 3, 2020
1 parent aac3b70 commit 2815b43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
20 changes: 11 additions & 9 deletions pages/templates/pages/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
{% endif %}

{% if show_siblings and logic_page.siblings %}
<ul class="breadcrumbs-siblings-links list-white">
{% for page in logic_page.siblings %}
<li>
<a href="{{ page.url }}" class="list-white-link">
{{ page.display_menu_title }}
</a>
</li>
{% endfor %}
</ul>
{% if show_last_page_siblings or not forloop.last %}
<ul class="breadcrumbs-siblings-links list-white">
{% for page in logic_page.siblings %}
<li>
<a href="{{ page.url }}" class="list-white-link">
{{ page.display_menu_title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}

<meta itemprop="position" content="{{ forloop.counter }}">
Expand Down
9 changes: 5 additions & 4 deletions pages/templatetags/pages_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
register = template.Library()


def _base_breadcrumbs(page: Page, separator='', *, show_siblings=False):
def _base_breadcrumbs(page: Page, separator='', *, show_siblings=False, show_last_page_siblings=False):
return {
'breadcrumbs': [
# @todo #345:60m Refold catalog pages in DB.
Expand All @@ -21,17 +21,18 @@ def _base_breadcrumbs(page: Page, separator='', *, show_siblings=False):
],
'separator': separator,
'show_siblings': show_siblings,
'show_last_page_siblings': show_last_page_siblings,
}


@register.inclusion_tag('pages/breadcrumbs.html')
def breadcrumbs(page: Page, separator=''):
return _base_breadcrumbs(page, separator, show_siblings=False)
return _base_breadcrumbs(page, separator, show_siblings=False, show_last_page_siblings=False)


@register.inclusion_tag('pages/breadcrumbs.html')
def breadcrumbs_with_siblings(page: Page, separator=''):
return _base_breadcrumbs(page, separator, show_siblings=True)
def breadcrumbs_with_siblings(page: Page, separator='', show_last_page_siblings=True):
return _base_breadcrumbs(page, separator, show_siblings=True, show_last_page_siblings=show_last_page_siblings)


@register.inclusion_tag('pages/accordion.html')
Expand Down

0 comments on commit 2815b43

Please sign in to comment.