Convert breadcrumb.html include into a custom tag

pull/3197/head
Matt Westcott 2016-12-01 14:52:47 +00:00
rodzic 44508fd7bb
commit 2a76a30e7b
5 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -8,7 +8,7 @@
{% block content %} {% block content %}
<header class="merged tab-merged nice-padding"> <header class="merged tab-merged nice-padding">
{% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page include_self=1 %} {% explorer_breadcrumb parent_page include_self=1 %}
<div class="row row-flush"> <div class="row row-flush">
<div class="left col9"> <div class="left col9">

Wyświetl plik

@ -8,7 +8,7 @@
{% block content %} {% block content %}
{% page_permissions page as page_perms %} {% page_permissions page as page_perms %}
<header class="merged tab-merged nice-padding"> <header class="merged tab-merged nice-padding">
{% include "wagtailadmin/shared/breadcrumb.html" with page=page %} {% explorer_breadcrumb page %}
<div class="row row-flush"> <div class="row row-flush">
<div class="left col9"> <div class="left col9">

Wyświetl plik

@ -7,7 +7,7 @@
<header class="merged no-border nice-padding no-v-padding"> <header class="merged no-border nice-padding no-v-padding">
<h1 class="visuallyhidden">Explorer</h1> <h1 class="visuallyhidden">Explorer</h1>
{% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page %} {% explorer_breadcrumb parent_page %}
</header> </header>
<form id="page-reorder-form"> <form id="page-reorder-form">

Wyświetl plik

@ -1,14 +1,11 @@
{% load i18n %} {% load i18n %}
<ul class="breadcrumb"> <ul class="breadcrumb">
{% for page in page.get_ancestors %} {% for page in pages %}
{% if page.is_root %} {% if page.is_root %}
<li class="home"><a href="{% url 'wagtailadmin_explore_root' %}" class="icon icon-home text-replace">{% trans 'Home' %}</a></li> <li class="home"><a href="{% url 'wagtailadmin_explore_root' %}" class="icon icon-home text-replace">{% trans 'Home' %}</a></li>
{% else %} {% else %}
<li><a href="{% url 'wagtailadmin_explore' page.id %}">{{ page.get_admin_display_title }}</a></li> <li><a href="{% url 'wagtailadmin_explore' page.id %}">{{ page.get_admin_display_title }}</a></li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if include_self %}
<li><a href="{% url 'wagtailadmin_explore' page.id %}">{{ page.get_admin_display_title }}</a></li>
{% endif %}
</ul> </ul>

Wyświetl plik

@ -55,6 +55,13 @@ def main_nav(context):
} }
@register.inclusion_tag('wagtailadmin/shared/breadcrumb.html')
def explorer_breadcrumb(page, include_self=False):
return {
'pages': page.get_ancestors(inclusive=include_self)
}
@register.inclusion_tag('wagtailadmin/shared/search_other.html', takes_context=True) @register.inclusion_tag('wagtailadmin/shared/search_other.html', takes_context=True)
def search_other(context, current=None): def search_other(context, current=None):
request = context['request'] request = context['request']