Skip to content

Commit

Permalink
Fixed Duplication of query params bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hashtagerrors committed Aug 11, 2019
1 parent 39c6f14 commit 2660da8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.2 - 2019-08-11
### Added
- Fixed Duplication of query params bug

## 1.0.1 - 2019-05-16
### Added
- Fixed FirstText and LastText Bug
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hashtagerrors/craft-pagination",
"description": "Pagination plugin for Craft 3",
"type": "craft-plugin",
"version": "1.0.1",
"version": "1.0.2",
"keywords": [
"craft",
"cms",
Expand Down
30 changes: 15 additions & 15 deletions src/templates/_render/_paginate.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,87 +22,87 @@

{% set showPageInfo = options.showPageInfo ?? '' %}

{% set appendUrl = craft.app.request.getQueryStringWithoutPath() ? '?'~craft.app.request.getQueryStringWithoutPath() : '' %}
{# {% set appendUrl = craft.app.request.getQueryStringWithoutPath() ? '?'~craft.app.request.getQueryStringWithoutPath() : '' %} #}

<ul class="{{ ulClass }}">
{% if type == 'firstNext' %}
{% if pageInfo.prevUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}{{ appendUrl }}">{{ prevText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}">{{ prevText|raw }}</a>
</li>
{% endif %}
{% if showPageInfo %}
<li class="showPageInfo">Page <span class="pageNow">{{ pageInfo.currentPage }}<span> of <span class="pageTotal">{{ pageInfo.totalPages }}<span></li>
{% endif %}
{% if pageInfo.nextUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}{{ appendUrl }}">{{ nextText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}">{{ nextText|raw }}</a>
</li>
{% endif %}
{% elseif type == 'ellipsis' %}
{% if pageInfo.prevUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}{{ appendUrl }}">{{ prevText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}">{{ prevText|raw }}</a>
</li>
{% endif %}
{% if pageInfo.currentPage > pageRange + 1 %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.firstUrl }}{{ appendUrl }}">1</a>
<a class="{{ aClass }}" href="{{ pageInfo.firstUrl }}">1</a>
</li>
{% endif %}
{% if pageInfo.currentPage > pageRange + 2 %}
<span class="pageEllipsis">...</span>
{% endif %}
{% for page, url in pageInfo.getPrevUrls(pageRange) %}
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}{{ appendUrl }}">{{ page }}</a></li>
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}">{{ page }}</a></li>
{% endfor %}
<li class="{{ liClass }} {{ activeClass }}">
<a class="{{ aClass }}" href="javascript:void(0);">{{ pageInfo.currentPage }}</a>
</li>
{% for page, url in pageInfo.getNextUrls(pageRange) %}
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}{{ appendUrl }}">{{ page }}</a></li>
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}">{{ page }}</a></li>
{% endfor %}
{% if pageInfo.currentPage < pageInfo.totalPages-(pageRange + 1) %}
<span class="pageEllipsis">...</span>
{% endif %}
{% if pageInfo.currentPage < pageInfo.totalPages-pageRange %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.lastUrl }}{{ appendUrl }}">{{ pageInfo.totalPages }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.lastUrl }}">{{ pageInfo.totalPages }}</a>
</li>
{% endif %}
{% if pageInfo.nextUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}{{ appendUrl }}">{{ nextText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}">{{ nextText|raw }}</a>
</li>
{% endif %}
{% else %}
{% if includeFirstLast %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.firstUrl }}{{ appendUrl }}">{{ firstText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.firstUrl }}">{{ firstText|raw }}</a>
</li>
{% endif %}
{% if includePrevNext and pageInfo.prevUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}{{ appendUrl }}">{{ prevText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.prevUrl }}">{{ prevText|raw }}</a>
</li>
{% endif %}
{% for page, url in pageInfo.getPrevUrls(pageRange) %}
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}{{ appendUrl }}">{{ page }}</a></li>
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}">{{ page }}</a></li>
{% endfor %}
<li class="{{ liClass }} {{ activeClass }}">
<a class="{{ aClass }}" href="javascript:void(0);">{{ pageInfo.currentPage }}</a>
</li>
{% for page, url in pageInfo.getNextUrls(pageRange) %}
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}{{ appendUrl }}">{{ page }}</a></li>
<li class="{{ liClass }}"><a class="{{ aClass }}" href="{{ url }}">{{ page }}</a></li>
{% endfor %}
{% if includePrevNext and pageInfo.nextUrl %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}{{ appendUrl }}">{{ nextText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.nextUrl }}">{{ nextText|raw }}</a>
</li>
{% endif %}
{% if includeFirstLast %}
<li class="{{ liClass }}">
<a class="{{ aClass }}" href="{{ pageInfo.lastUrl }}{{ appendUrl }}">{{ lastText|raw }}</a>
<a class="{{ aClass }}" href="{{ pageInfo.lastUrl }}">{{ lastText|raw }}</a>
</li>
{% endif %}
{% endif %}
Expand Down

0 comments on commit 2660da8

Please sign in to comment.