Forum

Thread tagged as: Question, Problem, Field-Types
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that sounds great - you should be able to output the same from here, should you not?

Im not quite sure how though as ive got the output of the collection using this template:

<div class="staff">
    <img src="<perch:content id="staffimage" />" />
    <h5><perch:content id="staffname" /></h5>
    <p><perch:content id="staffposition" /></p>
    <a href="/branches/<perch:content id="staffslug" type="slug" />"> View Profile</a>
</div>

Which correctly outputs the /branches/firstname_lastname but for some reason it says "You have included the Perch runtime in your page template. Please remove it - Runway will include it for you." so when i take the runtime out it defaults back to the branches/index.php page

Drew McLellan

Drew McLellan 2638 points
Perch Support

If the link is correct, then you don't need to worry about the template.

The issue then becomes the route and the page it's using. Does your slug literally have an underscore in it?

No i didnt use an underscore at i find sometimes it doesnt work but i havent really used slugs like this before

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you give an example of a real value?

Well i have the slug taking the info from the staff name so someone called john smith the output would be john-smith.

Then in the route i have the ID of that slug like: [slug:staffslug]

Drew McLellan

Drew McLellan 2638 points
Perch Support

Your full route should be:

branches/[slug:staffslug]

Is that what you have?

Yeah thats what i have in the perch routes under the page settings, but do i include that in the href in the template or just include the slug on its own?

Drew McLellan

Drew McLellan 2638 points
Perch Support

The href looks to be correct as you have it.

href="/branches/<perch:content id="staffslug" type="slug" />"

Hmmm its still going to a 404 error.

Debug message from the page but doesnt really say much

Debug Message
[119] 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, p.pagePath ASC
Using master page: /templates/pages/errors/404.php
Request time: 0.0691
Process time: 0.0584
Memory: 3.1595
Array
(
    [type] => 2
    [message] => include(): Failed opening '/Users/Xland/Desktop/lebc/perch/templates/pages/errors/404.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.26/lib/php')
    [file] => /Users/Xland/Desktop/lebc/perch/core/runway/start.php
    [line] => 32
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

That error is for the page /branches/john-smith ?

Correct

Drew McLellan

Drew McLellan 2638 points
Perch Support

Generally is routing working for you on the site?

Im not really sure, this is the first time ive used it

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does the Pages > Routes screen show in the control panel?

pattern: branches/[slug:staffslug]

Page: /branches/birmingham/index.php

order: 1

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. I'm not quite sure how to help at this point. It looks like it should be working to me.

Hmmm okay, i will have a look at it and go through the documentation and stuff again, thanks for all your help!

Hi Drew, think ive got to the bottom of this,

I think ive managed to get the routing to work but when you go to the page it says "You have included the Perch runtime in your page template. Please remove it - Runway will include it for you."

So if i remove the perch runway include from the doctype the page loads but for some reason it is using the branch.php master page template whereas it needs to be using the staff.php template but not sure how to dictate which master template it uses…

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's based on which master page is selected for that page in the page options.