Answers.Body: <p>Thank you so much for your detailed response Carl. As I was working to implement this solution I decided to go back and take a look at url segments (I am used to ExpressionEngine).   I found that craft.request has a whole series of properties including getPageNum() which gets the pagination page number from the url.   </p>
  
  <p>I changed the urls link in my pagination list to:</p>
  
  <pre><code>&lt;a href="{{ entry.url }}/p{{ craft.request.getPageNum() }}"&gt;
  </code></pre>
  
  <p>and that maintained the pagination position in the url which basically does what I need.</p>
  
  <p>Cheers,</p>
  
  <p>Alex</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T07:32:31.600Z
Answers.Text: That's great you found this simple solution. So, Craft is able to match the route example.com/my-section/my-entry/p2 to an entry with the slug my-entry and also gets the pagination page from the URL. Too bad you can't configure it to have the URLs more hierarchically correct as in example.com/my-section/p2/my-entry.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T06:14:38.787Z
Answers.LastActivityDate: 2015-05-19T07:26:52.480Z
Answers.LastEditDate: 2015-05-19T07:26:52.480Z
Answers.UserDisplayName: user1815670
Answers.Body: <p>You would need to pass the current pagination page number with your entry links and than make Craft
  respond to URLs in a format like this: example.com/my-section/p2/my-entry-slug.</p>
  
  <p>I guess this is more complicated than you'd think, as this is probably not possible to do with
  the default <code>paginate</code> tag and its preset routes. And I also don't know of a way to combine the <code>paginate</code>
  tag's page token with custom routes.</p>
  
  <p>So I believe there's no other choice left than replacing <code>paginate</code> with a custom solution replicating its
  functionality.</p>
  
  <p>This is possible with <a href="http://buildwithcraft.com/docs/routing#dynamic-routes" rel="nofollow">dynamic routes</a> and some logic in your templates. So you'd first have to set up a route
  with a <code>[page]</code> and a <code>[slug]</code> token, which you can then access in your template.</p>
  
  <p><code>my-section/p[page]/[slug]</code> and<br>
  <code>my-section/p[page]</code></p>
  
  <p>I'll give some example code (untested and incomplete), to help you get started with the template.</p>
  
  <p>All the pagination links build upon the route's <code>page</code> variable used in <code>craft.entries</code>'s <a href="http://buildwithcraft.com/docs/templating/craft.entries#offset" rel="nofollow"><code>offset</code></a> and <a href="http://buildwithcraft.com/docs/templating/craft.entries#limit" rel="nofollow"><code>limit</code></a> parameters. With custom routes you also have to query for your <code>entry</code> entry model manually, I set it up to get the page's first entry
  if there's no <code>slug</code> variable set from your route.</p>
  
  <pre><code>{# Set params #}
  {% set params = {section: 'orchard'} %}
  {% set entriesPerPage = 5 %}
  
  {% if page is defined %}
      {% set offsetParam = (page - 1) * entriesPerPage %}
      {% set pageSegment = '/p' ~ page %}
  {% else %}
      {% set offsetParam = 0 %}
      {% set pageSegment = '' %}
  {% endif %}
  
  {# Get the entry model #}
  {% if slug is defined %}
      {% set entry = craft.entries.slug(slug).first() %}
  {% else %}
      {% set entry = craft.entries(params).offset(offsetParam).first() %}
  {% endif %}
  
  {# Get pagination params #}
  {% if page is defined %}
      {% set entriesOnNextPage = craft.entries(params).offset(offsetParam + 1) %}
  
      {% if entriesOnNextPage|length %}
          {% set nextPageSegment = '/p' ~ page + 1 %}
      {% endif %}
  
      {% if page == 1 %}
          {% set prevPageSegment = '' %}
      {% else %}
          {% set prevPageSegment = '/p' ~ page - 1 %}
      {% endif %}
  {% else %}
      {% set entriesOnNextPage = craft.entries(params).offset(entriesPerPage) %}
  
      {% if entriesOnNextPage|length %}
          {% set nextPageSegment = '/p2' %}
      {% endif %}
  {% endif %}
  
  &lt;article&gt;
      &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;
  &lt;/article&gt;
  
  &lt;nav&gt;
      {% set entriesOnPage = craft.entries(params).offset(offsetParam).limit(entriesPerPage) %}
  
      {% for entry in entriesOnPage %}
          {% set image = entry.mediaThumb.first() %}
  
          &lt;a href="/my-section{{ pageSegment }}/{{ entry.slug }}"&gt;
              &lt;img src="{{ image.url }}"&gt;
          &lt;/a&gt;
      {% endfor %}
  
      {% if prevPageSegment is defined %}
          &lt;a href="/my-section{{ prevPageSegment }}"&gt;Previous Page&lt;/a&gt;
      {% endif %}
  
      {% if nextPageSegment is defined %}
          &lt;a href="/my-section{{ nextPageSegment }}"&gt;Next Page&lt;/a&gt;
      {% endif %}
  &lt;/nav&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T09:48:37.533Z
Answers.LastActivityDate: 2015-05-18T09:48:37.533Z
Answers.UserDisplayName: carlcs
Body: <p>I have managed to sort most Craft CMS questions out by reading the docs and feedback on StackExchange but am having issues with this one.</p>
  
  <p>I have a page with a list of entries down the right side and the main entry content to the left.</p>
  
  <p>The list is paginated.  When I go to say page 2 of the pagination and click on an entry, the page reloads with the page 1 pagination list.</p>
  
  <p>How can I get the page to remember that the entry belongs to page 2?</p>
  
  <pre><code>{% paginate craft.entries.section('orchard').limit('5').id('not ' ~ entry.id)  as entriesOnPage %}
  
   {% for entry in entriesOnPage %}
     {% for asset in entry.mediaThumb %}
       &lt;div class="shuntalittle"&gt;
        &lt;h6&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h6&gt;
        &lt;a href="{{ entry.url }}"&gt;
          &lt;img src="{{ asset.getUrl('thumbTransform') }}" alt="{{ asset.title }}"&gt;
        &lt;/a&gt;
       &lt;/div&gt;
     {% endfor %}    
   {% endfor %}
  
    &lt;div class="pagination-centered shuntalittle"&gt;
      &lt;ul class="pagination"&gt;
        {% if paginate.prevUrl %}
          &lt;li&gt;&lt;a href="{{ paginate.prevUrl }}" class="arrow"&gt;&amp;laquo;&lt;/a&gt;&lt;/li&gt;
        {% endif %}
        {% for page, url in paginate.getPrevUrls(5) %}
          &lt;li&gt;&lt;a href="{{ url }}"&gt;{{ page }}&lt;/a&gt;&lt;/li&gt;
        {% endfor %}
        &lt;li class="current"&gt;&lt;a href=""&gt;{{ paginate.currentPage }}&lt;/a&gt;&lt;/li&gt;
        {% for page, url in paginate.getNextUrls(5) %}
          &lt;li&gt;&lt;a href="{{ url }}"&gt;{{ page }}&lt;/a&gt;&lt;/li&gt;
        {% endfor %}
        {% if paginate.nextUrl %}
          &lt;li&gt;&lt;a href="{{ paginate.nextUrl }}" class="arrow"&gt;&amp;raquo;&lt;/a&gt;&lt;/li&gt;
        {% endif %}
      &lt;/ul&gt;
    &lt;/div&gt;
  {% endpaginate %}
  </code></pre>
  
  <p>Many thanks, Alex</p>
  
Tags: <pagination>
Title: relate pagination to entry on page
ThreadText: # relate pagination to entry on page
  
  (Asked by: username_0 on 2015-05-18)
  
  I have managed to sort most Craft CMS questions out by reading the docs and feedback on StackExchange but am having issues with this one.
  
  I have a page with a list of entries down the right side and the main entry content to the left.
  
  The list is paginated. When I go to say page 2 of the pagination and click on an entry, the page reloads with the page 1 pagination list.
  
  How can I get the page to remember that the entry belongs to page 2?
  
  ```
  {% paginate craft.entries.section('orchard').limit('5').id('not ' ~ entry.id)  as entriesOnPage %}
  
   {% for entry in entriesOnPage %}
     {% for asset in entry.mediaThumb %}
       <div class="shuntalittle">
        <h6><a href="{{ entry.url }}">{{ entry.title }}</a></h6>
        <a href="{{ entry.url }}">
          <img src="{{ asset.getUrl('thumbTransform') }}" alt="{{ asset.title }}">
        </a>
       </div>
     {% endfor %}    
   {% endfor %}
  
    <div class="pagination-centered shuntalittle">
      <ul class="pagination">
        {% if paginate.prevUrl %}
          <li><a href="{{ paginate.prevUrl }}" class="arrow">&laquo;</a></li>
        {% endif %}
        {% for page, url in paginate.getPrevUrls(5) %}
          <li><a href="{{ url }}">{{ page }}</a></li>
        {% endfor %}
        <li class="current"><a href="">{{ paginate.currentPage }}</a></li>
        {% for page, url in paginate.getNextUrls(5) %}
          <li><a href="{{ url }}">{{ page }}</a></li>
        {% endfor %}
        {% if paginate.nextUrl %}
          <li><a href="{{ paginate.nextUrl }}" class="arrow">&raquo;</a></li>
        {% endif %}
      </ul>
    </div>
  {% endpaginate %}
  
  ```
  
  Many thanks, Alex
  
  **Tags:** pagination
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-05-19. Score: 1
  
  Thank you so much for your detailed response Carl. As I was working to implement this solution I decided to go back and take a look at url segments (I am used to ExpressionEngine). I found that craft.request has a whole series of properties including getPageNum() which gets the pagination page number from the url.
  
  I changed the urls link in my pagination list to:
  
  ```
  <a href="{{ entry.url }}/p{{ craft.request.getPageNum() }}">
  
  ```
  
  and that maintained the pagination position in the url which basically does what I need.
  
  Cheers,
  
  Alex
  
  > **Comments:**
  > **username_1**: That's great you found this simple solution. So, Craft is able to match the route example.com/my-section/my-entry/p2 to an entry with the slug my-entry and also gets the pagination page from the URL. Too bad you can't configure it to have the URLs more hierarchically correct as in example.com/my-section/p2/my-entry.  
  
  ---
  
  ### Answer by username_1 on 2015-05-18. Score: 1
  
  You would need to pass the current pagination page number with your entry links and than make Craft
  respond to URLs in a format like this: example.com/my-section/p2/my-entry-slug.
  
  I guess this is more complicated than you'd think, as this is probably not possible to do with
  the default `paginate` tag and its preset routes. And I also don't know of a way to combine the `paginate`
  tag's page token with custom routes.
  
  So I believe there's no other choice left than replacing `paginate` with a custom solution replicating its
  functionality.
  
  This is possible with [dynamic routes](http://buildwithcraft.com/docs/routing#dynamic-routes) and some logic in your templates. So you'd first have to set up a route
  with a `[page]` and a `[slug]` token, which you can then access in your template.
  
  `my-section/p[page]/[slug]` and  
  `my-section/p[page]`
  
  I'll give some example code (untested and incomplete), to help you get started with the template.
  
  All the pagination links build upon the route's `page` variable used in `craft.entries`'s [`offset`](http://buildwithcraft.com/docs/templating/craft.entries#offset) and [`limit`](http://buildwithcraft.com/docs/templating/craft.entries#limit) parameters. With custom routes you also have to query for your `entry` entry model manually, I set it up to get the page's first entry
  if there's no `slug` variable set from your route.
  
  ```
  {# Set params #}
  {% set params = {section: 'orchard'} %}
  {% set entriesPerPage = 5 %}
  
  {% if page is defined %}
      {% set offsetParam = (page - 1) * entriesPerPage %}
      {% set pageSegment = '/p' ~ page %}
  {% else %}
      {% set offsetParam = 0 %}
      {% set pageSegment = '' %}
  {% endif %}
  
  {# Get the entry model #}
  {% if slug is defined %}
      {% set entry = craft.entries.slug(slug).first() %}
  {% else %}
      {% set entry = craft.entries(params).offset(offsetParam).first() %}
  {% endif %}
  
  {# Get pagination params #}
  {% if page is defined %}
      {% set entriesOnNextPage = craft.entries(params).offset(offsetParam + 1) %}
  
      {% if entriesOnNextPage|length %}
          {% set nextPageSegment = '/p' ~ page + 1 %}
      {% endif %}
  
      {% if page == 1 %}
          {% set prevPageSegment = '' %}
      {% else %}
          {% set prevPageSegment = '/p' ~ page - 1 %}
      {% endif %}
  {% else %}
      {% set entriesOnNextPage = craft.entries(params).offset(entriesPerPage) %}
  
      {% if entriesOnNextPage|length %}
          {% set nextPageSegment = '/p2' %}
      {% endif %}
  {% endif %}
  
  <article>
      <h2>{{ entry.title }}</h2>
  </article>
  
  <nav>
      {% set entriesOnPage = craft.entries(params).offset(offsetParam).limit(entriesPerPage) %}
  
      {% for entry in entriesOnPage %}
          {% set image = entry.mediaThumb.first() %}
  
          <a href="/my-section{{ pageSegment }}/{{ entry.slug }}">
              <img src="{{ image.url }}">
          </a>
      {% endfor %}
  
      {% if prevPageSegment is defined %}
          <a href="/my-section{{ prevPageSegment }}">Previous Page</a>
      {% endif %}
  
      {% if nextPageSegment is defined %}
          <a href="/my-section{{ nextPageSegment }}">Next Page</a>
      {% endif %}
  </nav>
  
  ```
  
  
  ---
  
  