Paging link rewrite not picking up section token/slug

  • Hi all


    Got a blog setup on Runway which uses sections. Standard index page setup which either displays posts for a section or all.


    Can't seem to get the paging to rewrite the section. The link generated just seems to output the next page number without the rewritten section.


    Expected url

    /en/news/section/events/2/


    Current url

    /en/news/section/2/


    Would it make any difference to have a section.php master page instead of using a conditional?

    Routes setup on page

    en/news/section/[slug:section]/[i:page]

    en/news/section/[slug:section]

    en/news/[i:page]

    blog/index.php

    blog-grid.html

  • If I manually navigate to /en/news/section/events/2/ the correct blog posts display.


    The debug has the following:


  • I ran into this issue yesterday myself. I'm sure I came across it in the past too. I often end up just using URL query string ?page=. So hopefully drewm will address this in v4 at least!


    Thinking about it now, you probably can use Perch conditional tags as the named segments you use in URL patterns are available to you (prefixed with url_)


    HTML
    1. <perch:if exists="url_section">section/<perch:blog id="url_section">/</perch:if>
  • It's one of those things that i'm pretty sure I have come across in the past before with runway and rewriting. Although I think it was a similar scenario with collections instead of the blog app.


    I think in the past I have passed in the cat/section slug into the function using data similar to below and built the url up, but it's good to know that the url tokens are available to use.


    Thanks for the clarification hus_hmd :thumbup:

    HTML
    1. <perch:if exists="paging">
    2. <div class="pagination">
    3. <perch:if exists="not_last_page">
    4. <perch:if exists="cat">
    5. <a href="/journal/category/<perch:content id="cat" type="hidden" />/<perch:content id="next_url" type="hidden" encode="false" rewrite="{page:%s/}" />" class="load-more button button--primary button--l" role="button">Show more</a>
    6. <perch:else />
    7. <a href="/journal/<perch:content id="next_url" type="hidden" encode="false" rewrite="{page:%s/}" />" class="load-more button button--primary button--l" role="button">Show more</a>
    8. </perch:if>
    9. </div>
    10. </perch:if>