Forum

Thread tagged as: Problem, Configuration, Runway

articles detail route Runway

Hi, I have a problem with routes in Runway. The page News Detail https://localhost/news/title is not working, show the news list instead of a detail page.

I'm using https://solutions.grabaperch.com/architecture/how-do-i-create-list-detail-pages

In Runway backend a have a Page called News Detail with path: /articles.php and route: news/[slug:s]

articles.php (templates>pages)

<?php
                     if (perch_get('s')) {

                          // Detail mode
                          perch_collection('News', [
                               'template' => 'articles_detail.html',
                               'filter'   => 'slug',
                               'value'    => perch_get('s'),
                               'count'    => 1,
                          ]); 

                     } else {

                          // List mode
                          perch_collection('News', [
                               'template' => 'articles_listing.html',
                               'sort' => 'date',
                              'paginate' => 'true',
                              'count' =>10
                          ]); 
                     }

                    ?>

template articles_detail.html

<section>
    <h2 class="post-title"><perch:content id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" title="true"/></h2>
    <perch:if exists="image">
        <div>
            <img src="<perch:content id="image" type="image" width="320" height="240" crop="true" label="Image" order="4" class="img-responsive imageborder" />" alt="<perch:content id="postTitle" />" />
        </div>
    </perch:if>

   <p class="vcard">
   <perch:content id="date" type="date" label="Date" format="%d %B %Y" />

    <span class="fn n">
        <perch:content id="author_given_name" type="text" label="Author given name" />
        <perch:content id="author_family_name" type="text" label="Author family name" /> 
    </span>  
    </p>

    <p><perch:content id="postDescHTML" type="textarea" label="Post" order="3" editor="markitup" markdown="true" size="xxl" required="true" /></p>
</section>

<perch:after>
  <perch:if exists="paging">
    <div class="paging">
      Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" />
      <perch:if exists="not_first_page">
        <a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>
      </perch:if>
      <perch:if exists="not_last_page">
        <a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
      </perch:if>
    </div>
  </perch:if>
</perch:after>
<perch:categories id="news" set="news" label="Category" display-as="checkboxes" suppress="true"></perch:categories></p>
<perch:content id="image" type="image" width="100" height="100" crop="true" suppress="true" />
<perch:content id="image" type="image" width="330" height="180" crop="true" suppress="true" />
<perch:content id="slug" type="slug" for="postTitle" editable="false" label="slug" suppress="true" />

Thanks in advance.

alex s

alex s 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, what does it output at the bottom of the detail view?

alex s

alex s 0 points

Hi Drew, Here goes! thanks.

Debug Message
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC
Matched route: news
Using master page: /templates/pages/articles.php
Page arguments:

Array
(
    [0] => news
)

SELECT * FROM perch2_pages WHERE pagePath='/articles.php' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/articles.php' OR pageSortPath='/articles.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-003', '000') ORDER BY pageTreePosition
Using template: /templates/navigation/breadcrumbs.html
SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='News'
SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='date' WHERE (idx.collectionID=1) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC LIMIT 0, 10
SELECT FOUND_ROWS() AS `count`
Using template: /templates/content/articles_listing.html
SELECT idx.itemID FROM perch2_collection_index idx JOIN perch2_collection_revisions c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.collectionID=c.collectionID WHERE (idx.collectionID=1) AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'news/molmed/%'))
SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='date' WHERE (idx.collectionID=1) AND idx.itemID IN (1, 3, 2) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 3
Using template: /templates/content/articles_sidebar.html
SELECT idx.itemID FROM perch2_collection_index idx JOIN perch2_collection_revisions c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.collectionID=c.collectionID WHERE (idx.collectionID=1) AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'news/external/%'))
SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='date' WHERE (idx.collectionID=1) AND idx.itemID IN (3, 7, 2) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 3
Using template: /templates/content/articles_sidebar.html
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Time: 0.1143
Memory: 4.7152
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's matching this route:

Matched route: news

What does the URL look like at that point, and what other routes do you have set up? Are they ordered as most-specific first?

alex s

alex s 0 points

Hi Drew,

I don't know, I don't configured other routes. No, no really.

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to add a route for your detail page.

alex s

alex s 0 points

Yes, I know. I changed the route order (first: news/[slug:s]) and It's working fine.

Thanks.