Forum

Thread tagged as: Problem, Discussion, Runway

Assistance needed with Routes

My current live site (aroundptown.com) runs Perch 2. It displays news story excerpts (which click through using list/detail setup). The latest excerpts are on the home page and then the excerpts are categorized and displayed at aroundptown.com/category.php?cat=setname/catname/.

I had this problem when I tried the upgrade before so I started over yesterday to have a clean slate. I copied the site, followed all directions for an upgrade to Runway and everything seems to work just fine, except the previous and next URLs in the pagination. After hours of searching and reading, I've come to the conclusion that I will need to set up routes on those pages, but I am not finding clear instructions on routing to the category AND to the page number. (I am positive that I can route to multiple things because I see it in the Perch forum on URLs like this one: https://forum.grabaperch.com/forum?page=4&tags=Runway)

The live site is at aroundptown.com. The home page next_url goes to "/?page=2" (3, 4 ...), as expected. Once you're on page 2 or higher, the prev_url goes to the home page or whatever the previous page is, as expected.

Trying from a live category page, https://aroundptown.com/category.php?cat=news/obituaries/ The next_url adds "&page=2" (3, 4 ...), as expected. Once you're on page 2 or higher, the prev_url goes to the category page (as listed above) or whatever the previous page is, as expected.

Once I get to the Runway site The home page next_url goes to "/?page=2" (3, 4 ...), as expected. BUT once you're on page 2 or higher, the prev_url stays on the same page you're on. (Page 3 stays on Page 3; Page 2 stays on Page 2.

From a Runway category page: The next_url takes away the category from the URL and replaces it with "&page=2", therefore removing the particular category designation and just displaying a list of every story in the collection (at "category.php?page=2"). If I go directly to the full, correct URL on page 2 or above, the prev_url stays on the same page you're on. (Page 3 stays on Page 3; Page 2 stays on Page 2.)

This is the portion of index.php calling the Collection (the only thing that has changed here is that it was perch_content_custom previously).

perch_collection('Stories', array(

    'category-match' => 'all',
      'sort' => 'postDateTime',
    'sort-order' => 'DESC',
    'template' => '_story_listing_home.html',
        'filter' => 'hide',
'match' => 'neq',
'value' => true,
    'paginate' => true,
    'count' => 5,

    ));

Same situation with category.php

perch_collection('Stories', array(
         'template' => 'story_listing.html',
    'category' => perch_get('cat'),
  'sort-order' => 'DESC',
                      'sort' => 'postDateTime',
                    'filter' => 'hide',
'match' => 'neq',
'value' => true,
                'paginate' => true,

                      'count' => 10,
    ));

This is the portion of story_listing.html & _story_listing_home.html with the pagination -- nothing has changed here between the live Perch 2 site and the Runway upgrade:

 <perch:if exists="paging">
  <div class="paging">

     <perch:if exists="not_first_page">
      <a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>&nbsp;&nbsp;
    </perch:if> 
    Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" />
    <perch:content id="page_links" encode="false" type="hidden" />
    <perch:if exists="not_last_page">
      &nbsp;&nbsp;<a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
    </perch:if>
  </div>
</perch:if>

I do not believe I need to move pages to master pages for this to work, but I cannot for the life of me figure out exactly what to put in the routes of either of these pages to make the pagination function correctly. Direction would be greatly appreciated!

Janel Stahr

Janel Stahr 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The first thing to do is to move your pages from out in your site root and turn them into master pages. I suspect that will fix your issue.