Forum
List and Detail then Detail page
I have a basic list and detail page working OK and have the detail page so to act as group/category area to list using a Perch repeater...
<h1><perch:content id="title" type="text" label="Product title" required="true" title="true" /></h1>
<perch:content id="image" type="image" label="Image" width="640" output="tag" />
<perch:content id="desc" type="textarea" label="Description" textile="true" editor="markitup" />
<perch:content id="slug" for="title" type="slug" suppress="true" />
<perch:content id="image" type="image" label="Image" width="100" height="100" crop="true" suppress="true" />
Then I've added a repeater to loop and add individual items in the group/list...
<perch:repeater id="fabric" label="Fabric">
<h2><perch:content id="title" type="text" label="Product title" required="true" title="true" /></h2>
<perch:content id="desc" type="textarea" label="Description" textile="true" size="xs" help="Give some clear description of this product" />
<img src="<perch:content type="image" id="image" label="Image" />"
alt="<perch:content type="text" id="alt" label="Image Description" />" />
<p>Price: £<perch:content id="Price" type="text" label="Price" format="#:2" help="Adjustment price" /></p>
</perch:repeater>
So far so good.
I'd like to ideally select one these repeated items to display it on it's own page, so it's kind of a List > Detail > Detail page.
Is this doable in Perch to single out individual repeated items? And how?
Or should I be approaching this in a different way?
You'd need to do it in the template with a
<perch:if>
How would <perch:if> single out one of the list of <perch:repeater> items?
You need something unique from the repeater - how are you forming the URL to this detail view?
I've got this in the repeater (although not necessarily 100% unique once an editor gets hold of it)
or perhaps could I grab 'id=perch_item_index', Would that be unique?
The plan was to just display that repeater item on shop.php
perch_item_index
would be unique, but would change if the repeater was reordered.It's more important how to filter one of the <perch:repeater> items to appear on shop.php
If you want to show item 2, you'd use
Mmm.. not sure if I'm approaching this right.
I'd never know how many repeaters the editor would have added short of adding an exhaustive <perch:if> template for every value
Is <perch:if> the only way to do this?
You don't need the
if
when generating the link.Sorry my bad yes. I'd still need it in the list template....
The detail page is already sorted on...
And so link needs to be (to get the repeater for that item)...
Which I don't know how to get the value of 'perch_item_index' back into the template. (it all works if I add a match manually)
...meaning I need the first id="title" available to the <perch:repeater> inner part of the template
Doing a <perch:showall /> tell me that any ID "outside" of the <perch:repeater> is not available the inside of <perch:repeater>
Can this be done?
... scope-parent="true" might help me here. Let me test this.
OK scope-parent="true" let's me properly format the query string to make it something like this...
And I have this on the shop page...
Using this template on the shop page...
But this lists "all" contents of the repeater.
How do I get both s=list-detail&p=single-repeater-item to sort the template?
I can't see where you're passing
p
into the template. Are you doing that?I ended up getting the "p" separately from the query string...
Then adding into Perch template...
And into the template to sort using if...
Is this the way I should be working with Perch?
Yes, except it's safer to use
perch_get()
over$_GET
.Is it now working?
Yes the basic principle is working just needs a tidy up.
How do I use perch_get() ?
Just change
to
Then it won't throw errors when
p
is not set, and it'll continue to work with routing if you upgrade to Runway in the future.Fantastic. Thanks.