<p>Not tested, but I would assume that you could simply get the total entries, divide by the pagination limit and then generate your dynamic nav using a range loop.</p>

<pre><code>{% set totalEntries = craft.entries.section('news').limit(null).total() %}
{% set pageLimit = 10 %}
{% set totalPages = (totalEntries / pageLimit)|round(0, 'ceil') %}

&lt;ul&gt;
    {% for i in range(1, totalPages) %}
        &lt;li&gt;&lt;a href="/news/p{{ i }}"&gt;&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
</code></pre>

CC BY-SA 3.0
2016-01-27T08:07:53.500Z
Good idea and might work in some cases (having replaced `find()` with total()`)  - but does not really work for me as the increment in `for` is adding 1, while it needs to add `pageLimit` - and if I add `pageLimit` as 3rd parameter for `range` I get `range(): step exceeds the specified range` error as initially number of entries is less then number of item per page. I need to get this done on Craft level, not on Twig level.
Yuri Salimovskiy
CC BY-SA 3.0
2016-01-28T09:17:32.090Z
Just to be clear `pageLimit` is the limit that you have defined for your elementCriteriaModel used by the pagination tag on the target page (i.e. on the news page). So by definition `totalEntries/pageLimit` rounded up should represent the total number of pages. The only other task is to create the same number of links as pages — thus the `range` loop. What is not working?
Douglas McDonald
CC BY-SA 3.0
2016-01-28T11:21:20.143Z
You're right, I just did not apply parameter to `total()` that I have in my entries loop, and so was getting unexpectable results. Your answer works, I only changed it to `range(2, totalPages)` (as I don't need first page) and  added `{% if totalEntries > pageLimit %}` because otherwise range is counting in reverse direction. Thank you very much!
Yuri Salimovskiy
CC BY-SA 3.0
2016-01-28T18:22:42.400Z
Great! I'm glad it worked. fyi... i updated answer with your `.total()` suggestion — much cleaner and probably saves some memory. Cheers.
Douglas McDonald
CC BY-SA 3.0
2016-01-26T19:08:43.463Z
2016-01-28T09:12:01.693Z
2016-01-28T09:12:01.693Z
Douglas McDonald
<p>Since version 3.1.28, you can set base URL of pagination links, like this:</p>

<pre><code>{% paginate query as pageInfo, pageEntries %}
{% do pageInfo.setBasePath('new_url') %}
</code></pre>

CC BY-SA 4.0
2019-05-21T21:38:39.647Z
2019-05-21T21:38:39.647Z
Piotr Pogorzelski
<p>TL;DR: Looking for something like <a href="https://docs.expressionengine.com/v2/templates/pagination.html#paginate-base" rel="nofollow">paginate_base</a> parameter in EE, but for Craft.</p>

<p>My site's homepage has content in tabs for different sections (news, products, etc.) and in each tab I would like to have pagination links that would go to 2nd, 3rd, etc page in each section.</p>

<p>So in News tab I display news entries and would like to link to /news/p2, /news/p3 etc, on Products tab I would have links to /products/p2, /products/p3 etc. All that on same page, with URL different from /news or /products</p>

<p>Is there any way to achieve that in Craft?</p>

<entries><pagination>
Pagination base URL - any way to have pagination links go to URLs other than current one?
# Pagination base URL - any way to have pagination links go to URLs other than current one?

(Asked by: username_0 on 2016-01-26)

TL;DR: Looking for something like [paginate\_base](https://docs.expressionengine.com/v2/templates/pagination.html#paginate-base) parameter in EE, but for Craft.

My site's homepage has content in tabs for different sections (news, products, etc.) and in each tab I would like to have pagination links that would go to 2nd, 3rd, etc page in each section.

So in News tab I display news entries and would like to link to /news/p2, /news/p3 etc, on Products tab I would have links to /products/p2, /products/p3 etc. All that on same page, with URL different from /news or /products

Is there any way to achieve that in Craft?

**Tags:** entries, pagination


---

## 2 answers

### Answer by username_1 on 2016-01-26. Score: 3 | Accepted answer

Not tested, but I would assume that you could simply get the total entries, divide by the pagination limit and then generate your dynamic nav using a range loop.
{% set totalEntries = craft.entries.section('news').limit(null).total() %}
{% set pageLimit = 10 %}
{% set totalPages = (totalEntries / pageLimit)|round(0, 'ceil') %}


    {% for i in range(1, totalPages) %}
        
    {% endfor %}

> **Comments:**
> **username_0**: Good idea and might work in some cases (having replaced `find()` with total()`)  - but does not really work for me as the increment in `for` is adding 1, while it needs to add `pageLimit` - and if I add `pageLimit` as 3rd parameter for `range` I get `range(): step exceeds the specified range` error as initially number of entries is less then number of item per page. I need to get this done on Craft level, not on Twig level.  
> **username_1**: Just to be clear `pageLimit` is the limit that you have defined for your elementCriteriaModel used by the pagination tag on the target page (i.e. on the news page). So by definition `totalEntries/pageLimit` rounded up should represent the total number of pages. The only other task is to create the same number of links as pages — thus the `range` loop. What is not working?  
> **username_0**: You're right, I just did not apply parameter to `total()` that I have in my entries loop, and so was getting unexpectable results. Your answer works, I only changed it to `range(2, totalPages)` (as I don't need first page) and  added `{% if totalEntries > pageLimit %}` because otherwise range is counting in reverse direction. Thank you very much!  
> **username_1**: Great! I'm glad it worked. fyi... i updated answer with your `.total()` suggestion — much cleaner and probably saves some memory. Cheers.  

---

### Answer by username_2 on 2019-05-21. Score: 3

Since version 3.1.28, you can set base URL of pagination links, like this:
{% paginate query as pageInfo, pageEntries %}
{% do pageInfo.setBasePath('new_url') %}


---

