Forum

Thread tagged as: Question, Runway

List/detail with collections

Hi

I'm using Perch Runway for the first time.

I've set up a list/detail collection and all is working fine.

I've got a list view in projects.php

I've created a second page for the detail. This is called project.php

The route is set up on this page to projects/[slug:s].

How do I prevent people browsing to the project.php page?

Basically I don't want sitename/project/ to be visible/navigable. I want all traffic to appear to route through the projects page.

I've probably done this wrong so if someone could point me in the right direction I would be most grateful.

Kind regards

Jon

Jonathan Elliman

Jonathan Elliman 27 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you created these as master pages under /perch/templates/pages ?

Yes sir. Should I be doing a php redirect if shlurrg is empty? I am high on Skittles so brain very slow.

I've done it like this before with perch_content_custom, but it should work with collections also.

$result = perch_content_custom('Collections',[
    'filter'=>'slug',
    'match'=>'eq',
    'value'=>perch_get('s'),
    'skip-template'=>true,
    'return-html'=>true
]);

if (empty(array_filter($result))) {
    // slug doesn't exist, go to first collection item
    $slug = perch_content_custom('Collections',[
        'count'=>1,
        'skip-template'=>true,
        'return-html'=>true
    ]);
    header('Location: https://'.$_SERVER['SERVER_NAME'].'/collections/'.$slug[0]['slug']);
} 

Shane. You're a God amongst men. Thank you!

Jon

Glad it helped!