Forum

Thread tagged as: Problem, Runway

Named Segments

Hi,

Sorry for the long post but I'm struggling to get my head around Named Segments and URL Patterns, I'm getting myself all confused I think.

I've got to a page that lists all my Brands (which is a Collection).

perch_collection('Brands',[
    'template' => 'collections/watch_brandlist.html'
]);

That template then just has the line:

<p>Brand: <a href="watches/<perch:content id="slug" type="slug" />"><perch:content id="brand" type="text" /></a></p>

So id of 'slug' is effectively matching the path of the page I have.

Another example I go to watches/bremont by clicking the link I've created above. This page then has a template and also a link to a page that lists that watches groups. I want to pass to this page the Brand that it should look up the Group names with so that page can use that Brand I've passed to it.

This is where I'm stuck.

<?php perch_content('Brand'); ?>
<a href="/watches/[slug:brand]/">Groups</a>

Now I know the bit above makes no sense but does it help to illustrate how confused I've got about this whole thing?

I've read as much as I can find about it and I'm still quite confused, any help at all would be fantastic!

Thanks for taking the time to read, Chris.

Chris Comben

Chris Comben 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you want to do something like this:

perch_collection('Brands',[
    'template' => 'collections/watch_brandlist.html',
    'filter' => 'slug', 
    'match' => 'eq', 
    'value' => perch_get('brand'),
]);

Thanks but I've got the brands list back ok, as I want all of them listed anyway. Its the next step really, how do I go about passing the brand I'm about to click on to the next page?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Oh, ok. I think you need something like:

 <a href="/watches/<?php echo PerchUtil::html(perch_get('brand')); ?>">Groups</a>