Forum
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.
If you turn on debug, what does it output at the bottom of the detail view?
Hi Drew, Here goes! thanks.
It's matching this route:
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?
Hi Drew,
I don't know, I don't configured other routes. No, no really.
Thanks.
You need to add a route for your detail page.
Yes, I know. I changed the route order (first: news/[slug:s]) and It's working fine.
Thanks.