Hello Team,
I am using pagination and langswitcher plugins. There is no problem when I list the posts (90 posts, limit: 10) in the predefined language (EN), 9 different pages (pagination|length) are created (page:1…to page:9) by plugin.
However, when I try to view the posts in other language (FR which has 4 posts), I still see 9 pagination pages. How can I filter paginate.number by language?
{% set options = { items: {'@self.children':''} } %}
{% set pagination = pagination|default(page.collection(options).params.pagination) %}
{% set language = grav.language.getLanguage %}
{% set base_url = base_url|default(page.url) %}
{% if pagination|length > 1 %}
<ul class="pagination">
{% if pagination.hasPrev %}
{% set url = (base_url ~ pagination.params ~ pagination.prevUrl)|replace({'//':'/'}) %}
<li><a rel="prev" href="{{ url }}">«</a></li>
{% else %}
<li><span>«</span></li>
{% endif %}
{% for paginate in pagination %}
{% if paginate.isCurrent %}
<li><span class="active">{{ paginate.number }}</span></li>
{% elseif paginate.isInDelta %}
{% set url = (base_url ~ pagination.params ~ paginate.url)|replace({'//':'/'}) %}
<li><a href="{{ url }}">{{ paginate.number }}</a></li>
{% elseif paginate.isDeltaBorder %}
<li class="gap"><span>…</span></li>
{% endif %}
{% endfor %}
{% if pagination.hasNext %}
{% set url = (base_url ~ pagination.params ~ pagination.nextUrl)|replace({'//':'/'}) %}
<li><a rel="next" href="{{ url }}">»</a></li>
{% else %}
<li><span>»</span></li>
{% endif %}
</ul>
{% endif %}
Thank you.