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
PHP
- <?php
- $slug = perch_get('section');
- if ($slug) {
- perch_blog_custom([
- 'data' => [
- 'section' => $slug,
- ],
- 'template' => 'blog-grid.html',
- 'count' => 9,
- 'sort' => 'postDateTime',
- 'sort-order' => 'DESC',
- 'blog' => $vars['lang'],
- 'section' => $slug,
- ]);
- } else {
- perch_blog_custom([
- 'template' => 'blog-grid.html',
- 'count' => 9,
- 'sort' => 'postDateTime',
- 'sort-order' => 'DESC',
- 'blog' => $vars['lang'],
- ]);
- }
- ?>
blog-grid.html
HTML
- <perch:after>
- </div>
- <perch:if exists="paging">
- <div class="row ta-c">
- <div class="col-12 ta-c eq-margin">
- <div class="h3">
- <perch:trans id="lang.global.paging.page" /> <perch:blog id="current_page" /> <perch:trans id="lang.global.paging.of" /> <perch:blog id="number_of_pages" />
- </div>
- <perch:if exists="not_first_page">
- <a class="btn btn--skew btn--fill" href="<perch:blog id="perch_page_path" />/<perch:blog id="prev_url" encode="false" rewrite="{section:/section/%s/}{page:%s/}" />"><span><perch:trans id="lang.global.prev" /></span></a>
- <perch:else />
- <span class="btn btn--skew btn--disabled"><span><perch:trans id="lang.global.prev" /></span></span>
- </perch:if>
- <perch:if exists="not_last_page">
- <a class="btn btn--skew btn--fill" href="<perch:blog id="perch_page_path" />/<perch:blog id="next_url" encode="false" rewrite="{section:/section/%s/}{page:%s/}" />"><span><span><perch:trans id="lang.global.next" /></span></a>
- <perch:else />
- <span class="btn btn--skew btn--disabled"><span><span><perch:trans id="lang.global.next" /></span></span>
- </perch:if>
- </div>
- </div>
- </perch:if>
- </perch:after>