Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Separate breadcrumb block

akjanik5df4d3ce64b5
diff --git a/saleor/product/views.py b/saleor/product/views.py
index d8e004c619..83a93339dd 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -125,12 +125,13 @@ def category_index(request, path, category_id):
now_sorted_by = get_now_sorted_by(product_filter)
arg_sort_by = request.GET.get('sort_by')
is_descending = arg_sort_by.startswith('-') if arg_sort_by else False
- ctx = {'wrap': category, 'filter_set': product_filter,
- 'products': products_and_availability,
- 'products_paginated': products_paginated,
- 'sort_by_choices': SORT_BY_FIELDS,
- 'now_sorted_by': now_sorted_by,
- 'is_descending': is_descending}
+ ctx = {
+ 'object': category, 'filter_set': product_filter,
+ 'products': products_and_availability,
+ 'products_paginated': products_paginated,
+ 'sort_by_choices': SORT_BY_FIELDS,
+ 'now_sorted_by': now_sorted_by,
+ 'is_descending': is_descending}
return TemplateResponse(request, 'category/index.html', ctx)
@@ -147,10 +148,11 @@ def collection_index(request, pk):
now_sorted_by = get_now_sorted_by(product_filter)
arg_sort_by = request.GET.get('sort_by')
is_descending = arg_sort_by.startswith('-') if arg_sort_by else False
- ctx = {'wrap': collection, 'filter_set': product_filter,
- 'products': products_and_availability,
- 'products_paginated': products_paginated,
- 'sort_by_choices': SORT_BY_FIELDS,
- 'now_sorted_by': now_sorted_by,
- 'is_descending': is_descending}
+ ctx = {
+ 'object': collection, 'filter_set': product_filter,
+ 'products': products_and_availability,
+ 'products_paginated': products_paginated,
+ 'sort_by_choices': SORT_BY_FIELDS,
+ 'now_sorted_by': now_sorted_by,
+ 'is_descending': is_descending}
return TemplateResponse(request, 'collection/index.html', ctx)
diff --git a/templates/category/_items.html b/templates/category/_items.html
deleted file mode 100644
index eaaf9784ed..0000000000
--- a/templates/category/_items.html
+++ /dev/null
@@ -1,42 +0,0 @@
-{% load i18n %}
-{% load staticfiles %}
-{% load price_range from price_ranges %}
-{% load product_first_image from product_images %}
-{% load get_thumbnail from product_images %}
-{% load placeholder %}
-
-{% for product, availability in products %}
-<div class="col-6 col-lg-3 product-list">
- <a href="{{ product.get_absolute_url }}" class="link--clean">
- <div class="text-center">
- <div>
- <img class="img-responsive lazyload lazypreload"
- data-src="{% product_first_image product method="crop" size="255x255" %}"
- data-srcset="{% product_first_image product method="crop" size="255x255" %} 1x, {% product_first_image product method="crop" size="510x510" %} 2x"
- alt=""
- src="{% placeholder size=255 %}">
- <span class="product-list-item-name" title="{{ product }}">{{ product }}</span>
- </div>
-
- <div class="panel-footer">
- {% if availability.available %}
- {% price_range availability.price_range %}
- {% if availability.discount %}
- {% if availability.price_range_undiscounted.min_price != availability.price_range.min_price %}
- <div class="product-list__sale">
- <svg data-src="{% static "images/sale-bg.svg" %}" />
- <span class="product-list__sale__text">
- {% comment %}Translators: Layout may break if character length is different than four.{% endcomment %}
- {% trans "Sale" context "Sale (discount) label for item in product list" %}
- </span>
- </div>
- {% endif %}
- {% endif %}
- {% else %}
- &nbsp;
- {% endif %}
- </div>
- </div>
- </a>
-</div>
-{% endfor %}
diff --git a/templates/category/_list.html b/templates/category/_list.html
deleted file mode 100644
index ef44009c32..0000000000
--- a/templates/category/_list.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{% load mptt_tags %}
-
-{% recursetree categories %}
- <li>
- <a href="{{ node.get_absolute_url }}">{{ node }}</a>
- {% if not node.is_leaf_node %}
- <ul class="children">
- {{ children }}
- </ul>
- {% endif %}
- </li>
-{% endrecursetree %}
diff --git a/templates/category/category_filters.html b/templates/category/filters.html
similarity index 77%
rename from templates/category/category_filters.html
rename to templates/category/filters.html
index dd8d91e21e..d709fda146 100644
--- a/templates/category/category_filters.html
+++ b/templates/category/filters.html
@@ -1,9 +1,9 @@
-{% extends "../product_filters.html" %}
+{% extends "product/_filters.html"%}
{% block title_tree %}
<div class="product-filters__categories">
<ul class="product-filters__categories__childs no-parent">
- {% for child in wrap.get_children %}
+ {% for child in category.get_children %}
<li>
<a href="{{ child.get_absolute_url }}">{{ child.name }}</a>
</li>
diff --git a/templates/category/index.html b/templates/category/index.html
index 0e5fde485e..dfa1229442 100644
--- a/templates/category/index.html
+++ b/templates/category/index.html
@@ -2,6 +2,18 @@
{% load i18n %}
{% load staticfiles %}
+{% block breadcrumb %}
+ <div class="col-md-7">
+ <ul class="breadcrumbs list-unstyled d-none d-md-block">
+ <li><a href="{% url 'home' %}">{% trans "Home" context 'Category breadcrumbs home' %}</a></li>
+ {% for ancestor in object.get_ancestors %}
+ <li><a href='{{ ancestor.get_absolute_url }}'>{{ ancestor.name }}</a></li>
+ {% endfor %}
+ <li><a href='{{ object.get_absolute_url }}'>{{ object.name }}</a></li>
+ </ul>
+ </div>
+{% endblock breadcrumb %}
+
{% block filters %}
- {% include "category/category_filters.html" %}
+ {% include "category/filters.html" with category=object %}
{% endblock filters %}
diff --git a/templates/collection/_items.html b/templates/collection/_items.html
deleted file mode 100644
index 549d6ac251..0000000000
--- a/templates/collection/_items.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{% load i18n %}
-{% load staticfiles %}
-{% load price_range from price_ranges %}
-{% load product_first_image from product_images %}
-{% load get_thumbnail from product_images %}
-
-{% for product, availability in products %}
-<div class="col-6 col-lg-3 product-list">
- <a href="{{ product.get_absolute_url }}" class="link--clean">
- <div class="text-center">
- <div>
- <img class="img-responsive"
- src="{% product_first_image product method="crop" size="255x255" %}"
- srcset="{% product_first_image product method="crop" size="255x255" %} 1x, {% product_first_image product method="crop" size="510x510" %} 2x"
- alt="">
- <span class="product-list-item-name" title="{{ product }}">{{ product }}</span>
- </div>
-
- <div class="panel-footer">
- {% if availability.available %}
- {% price_range availability.price_range %}
- {% if availability.discount %}
- {% if availability.price_range_undiscounted.min_price != availability.price_range.min_price %}
- <div class="product-list__sale">
- <svg data-src="{% static "images/sale-bg.svg" %}" />
- <span class="product-list__sale__text">
- {% comment %}Translators: Layout may break if character length is different than four.{% endcomment %}
- {% trans "Sale" context "Sale (discount) label for item in product list" %}
- </span>
- </div>
- {% endif %}
- {% endif %}
- {% else %}
- &nbsp;
- {% endif %}
- </div>
- </div>
- </a>
-</div>
-{% endfor %}
diff --git a/templates/collection/_list.html b/templates/collection/_list.html
deleted file mode 100644
index 20d36c4a27..0000000000
--- a/templates/collection/_list.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{#{% load mptt_tags %}#}
-{##}
-{#{% recursetree collections %}#}
-{# <li>#}
-{# <a href="{{ node.get_absolute_url }}">{{ node }}</a>#}
-{# {% if not node.is_leaf_node %}#}
-{# <ul class="children">#}
-{# {{ children }}#}
-{# </ul>#}
-{# {% endif %}#}
-{# </li>#}
-{#{% endrecursetree %}#}
diff --git a/templates/collection/index.html b/templates/collection/index.html
index 7754481e19..d6d02b7ba0 100644
--- a/templates/collection/index.html
+++ b/templates/collection/index.html
@@ -3,5 +3,5 @@
{% load staticfiles %}
{% block filters %}
- {% include "../product_filters.html" %}
+ {% include "product/_filters.html" %}
{% endblock filters %}
diff --git a/templates/home.html b/templates/home.html
index 024e7ee223..749fd61c7d 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -49,7 +49,7 @@
<div class="home__featured">
<h2 class="text-center">{% trans "Featured products" context "Homepage title" %}</h2>
<div class="row">
- {% include "category/_items.html" %}
+ {% include "product/_items.html" %}
</div>
</div>
<script type="application/ld+json">{{ webpage_schema|safe }}</script>
diff --git a/templates/product_filters.html b/templates/product/_filters.html
similarity index 98%
rename from templates/product_filters.html
rename to templates/product/_filters.html
index 8fb6e535ce..785b0b90d7 100644
--- a/templates/product_filters.html
+++ b/templates/product/_filters.html
@@ -4,7 +4,7 @@
<div class="product-filters">
<div class="product-filters__title">
<h2>
- <strong>{{ wrap }}</strong>
+ <strong>{{ object }}</strong>
</h2>
{% block title_tree %}{% endblock title_tree %}
</div>
@@ -13,7 +13,7 @@
<h2>
{% trans 'Filters' context 'Filter heading title' %}
{% if filter.is_bound_unsorted %}
- <a href=".">
+ <a href="../">
<span class="clear-filters float-right">{% trans 'Clear filters' context 'Product list page filters' %}</span>
</a>
{% endif %}
diff --git a/templates/product/_items.html b/templates/product/_items.html
index 549d6ac251..5b7fe94477 100644
--- a/templates/product/_items.html
+++ b/templates/product/_items.html
@@ -5,36 +5,35 @@
{% load get_thumbnail from product_images %}
{% for product, availability in products %}
-<div class="col-6 col-lg-3 product-list">
- <a href="{{ product.get_absolute_url }}" class="link--clean">
- <div class="text-center">
- <div>
- <img class="img-responsive"
- src="{% product_first_image product method="crop" size="255x255" %}"
- srcset="{% product_first_image product method="crop" size="255x255" %} 1x, {% product_first_image product method="crop" size="510x510" %} 2x"
- alt="">
- <span class="product-list-item-name" title="{{ product }}">{{ product }}</span>
- </div>
-
- <div class="panel-footer">
- {% if availability.available %}
- {% price_range availability.price_range %}
- {% if availability.discount %}
- {% if availability.price_range_undiscounted.min_price != availability.price_range.min_price %}
- <div class="product-list__sale">
- <svg data-src="{% static "images/sale-bg.svg" %}" />
- <span class="product-list__sale__text">
- {% comment %}Translators: Layout may break if character length is different than four.{% endcomment %}
- {% trans "Sale" context "Sale (discount) label for item in product list" %}
- </span>
- </div>
+ <div class="col-6 col-lg-3 product-list">
+ <a href="{{ product.get_absolute_url }}" class="link--clean">
+ <div class="text-center">
+ <div>
+ <img class="img-responsive"
+ src="{% product_first_image product method="crop" size="255x255" %}"
+ srcset="{% product_first_image product method="crop" size="255x255" %} 1x, {% product_first_image product method="crop" size="510x510" %} 2x"
+ alt="">
+ <span class="product-list-item-name" title="{{ product }}">{{ product }}</span>
+ </div>
+ <div class="panel-footer">
+ {% if availability.available %}
+ {% price_range availability.price_range %}
+ {% if availability.discount %}
+ {% if availability.price_range_undiscounted.min_price != availability.price_range.min_price %}
+ <div class="product-list__sale">
+ <svg data-src="{% static "images/sale-bg.svg" %}" />
+ <span class="product-list__sale__text">
+ {% comment %}Translators: Layout may break if character length is different than four.{% endcomment %}
+ {% trans "Sale" context "Sale (discount) label for item in product list" %}
+ </span>
+ </div>
+ {% endif %}
{% endif %}
+ {% else %}
+ &nbsp;
{% endif %}
- {% else %}
- &nbsp;
- {% endif %}
+ </div>
</div>
- </div>
- </a>
-</div>
+ </a>
+ </div>
{% endfor %}
diff --git a/templates/product_list_base.html b/templates/product_list_base.html
index f7015d8cd2..69bcf1c865 100644
--- a/templates/product_list_base.html
+++ b/templates/product_list_base.html
@@ -10,40 +10,39 @@
{{ block.super }}
{% endblock footer_scripts %}
-{% block title %}{{ wrap }} — {{ block.super }}{% endblock %}
+{% block title %}{{ object }} — {{ block.super }}{% endblock %}
{% block meta_tags %}
- <meta property="og:title" content="{{ wrap }}">
- <meta property="og:description" content="{{ wrap.description }}">
+ <meta property="og:title" content="{{ object }}">
+ <meta property="og:description" content="{{ object.description }}">
<meta property="og:image" content="{% static "images/block1.png" %}">
- {% build_absolute_uri request=request location=wrap.get_absolute_url as wrap_url %}
- <meta property="og:url" content="{{ wrap_url }}">
- <link rel="canonical" href="{{ wrap_url }}?page={{ products_paginated.number }}">
+ {% build_absolute_uri request=request location=object.get_absolute_url as object_url %}
+ <meta property="og:url" content="{{ object_url }}">
+ <link rel="canonical" href="{{ object_url }}?page={{ products_paginated.number }}">
{% if products_paginated.has_previous %}
- <link rel="prev" href="{{ wrap_url }}?page={{ products_paginated.previous_page_number }}">
+ <link rel="prev" href="{{ object_url }}?page={{ products_paginated.previous_page_number }}">
{% endif %}
{% if products_paginated.has_next %}
- <link rel="next" href="{{ wrap_url }}?page={{ products_paginated.next_page_number }}">
+ <link rel="next" href="{{ object_url }}?page={{ products_paginated.next_page_number }}">
{% endif %}
{% endblock meta_tags %}
+{% block breadcrumb %}
+ <div class="col-md-7">
+ <ul class="breadcrumbs list-unstyled d-none d-md-block">
+ <li><a href="{% url 'home' %}">{% trans "Home" context 'Site breadcrumbs home' %}</a></li>
+ <li><a href='{{ object.get_absolute_url }}'>{{ object.name }}</a></li>
+ </ul>
+ </div>
+{% endblock breadcrumb %}
{% block content %}
<div id="product-list-page">
<div class="product-list-top">
<div class="row">
- <div class="col-md-7">
- <ul class="breadcrumbs list-unstyled d-none d-md-block">
- <li><a href="{% url 'home' %}">{% trans "Home" context 'Category breadcrumbs home' %}</a></li>
- {% for ancestor in wrap.get_ancestors %}
- <li><a href='{{ ancestor.get_absolute_url }}'>{{ ancestor.name }}</a></li>
- {% endfor %}
- <li><a href='{{ wrap.get_absolute_url }}'>{{ wrap.name }}</a></li>
- </ul>
- </div>
<div class="col-md-5 filters-menu__wrapper">
<div class="row">
<div class="col-6 col-md-2 col-lg-6 filters-menu">
diff --git a/templates/search/results.html b/templates/search/results.html
index b4e619880b..f4a27f2618 100644
--- a/templates/search/results.html
+++ b/templates/search/results.html
@@ -23,7 +23,7 @@
<div class="col-12">
{% if query and results %}
<div class="row">
- {% include "category/_items.html" with products=results %}
+ {% include "product/_items.html" with products=results %}
</div>
{% bootstrap_pagination results url=query_string %}
{% else %}