Skip to content

Commit a70ca74

Browse files
committed
Add filter button functionality
1 parent 13e1c09 commit a70ca74

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

DjangoEcommerceApp/templates/admin_templates/product_list.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<div class="card-body">
2121
<form method="get">
2222
<button class="btn btn-primary" type="submit" style="float:right"><i class="fas fa-search"></i> Search</button>
23-
<input class="form-control" type="search" placeholder="Search" aria-label="Search" data-width="250" style="width: 250px;float:right" name="filter" value="{{ filter }}">
23+
<input class="form-control" type="search" placeholder="Search" aria-label="Search" data-width="250" style="width: 250px;float:right" name="search" value="{{ search }}">
2424
</form>
2525
</div>
2626

@@ -32,12 +32,25 @@
3232
<div class="col-lg-12">
3333
<div class="search-element">
3434
<div class="card">
35-
3635
<div class="card-body">
3736
<b>Sort By : - </b>
38-
<a href="{% url 'product_list' %}?filter={{ filter }}&orderby=id">ID</a> |
39-
<a href="{% url 'product_list' %}?filter={{ filter }}&orderby=product_name">Title</a> |
40-
<a href="{% url 'product_list' %}?filter={{ filter }}&orderby=product_description">Description</a>
37+
<a href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby=id">ID</a> |
38+
<a href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby=product_name">Title</a> |
39+
<a href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby=product_description">Description</a>
40+
</div>
41+
<div class="card-body dropdown">
42+
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu2"
43+
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
44+
Filter
45+
</button>
46+
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
47+
{% for subCategories in all_subCategories %}
48+
<a href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}"
49+
class="dropdown-item">
50+
{{ subCategories.title}}
51+
</a>
52+
{% endfor %}
53+
</div>
4154
</div>
4255
</div>
4356
</div>
@@ -83,15 +96,15 @@
8396
<nav aria-label="Page navigation example">
8497
<ul class="pagination">
8598
{% if page_obj.has_previous %}
86-
<li class="page-item"><a class="page-link" href="{% url 'product_list' %}?filter={{ filter }}&orderby={{ orderby }}&page={{ page_obj.previous_page_number }}">Previous</a></li>
99+
<li class="page-item"><a class="page-link" href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby={{ orderby }}&page={{ page_obj.previous_page_number }}">Previous</a></li>
87100
{% else %}
88101
<li class="page-item disabled"><a class="page-link" href="#">Previous</a></li>
89102
{% endif %}
90103
{% for i in paginator.page_range %}
91-
<li class="page-item {% if i == page_obj.number %}active{% endif %}"><a class="page-link" href="{% url 'product_list' %}?filter={{ filter }}&orderby={{ orderby }}&page={{ i }}">{{ i }}</a></li>
104+
<li class="page-item {% if i == page_obj.number %}active{% endif %}"><a class="page-link" href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby={{ orderby }}&page={{ i }}">{{ i }}</a></li>
92105
{% endfor %}
93106
{% if page_obj.has_next %}
94-
<li class="page-item"><a class="page-link" href="{% url 'product_list' %}?filter={{ filter }}&orderby={{ orderby }}&page={{ page_obj.next_page_number }}">Next</a></li>
107+
<li class="page-item"><a class="page-link" href="{% url 'product_list' %}?subcategories_id={{ subCategories.id }}&orderby={{ orderby }}&page={{ page_obj.next_page_number }}">Next</a></li>
95108
{% else %}
96109
<li class="page-item disabled"><a class="page-link" href="#">Next</a></li>
97110
{% endif %}

0 commit comments

Comments
 (0)