Forum
Pull specific item from a shared region using a dataselect field
Hi there,
I have a shared region called Testimonials
. My client wants to pull out specific testimonial from that shared region on certain inner pages. Rather than making them enter duplicates in a new region, I wanted to know if it's possible to populate a dataselect and give them control to select which one they'd like.
I have a template for my new region called Testimonials Specific
. Which contains:
<perch:content type="dataselect" id="testimonials" label="Testimonials" region="Testimonials" order="1" options="name" required="true" page="*" />
This works in that it populates the dataselect with the name of the client from each testimonial for the user to select. The next part I'm stuck on, is how - using this - I can use the ID of the item to pull out the entire contents of said item. I am guessing it'd be perch_content_custom
. Any pointing in the right direction would be appreciated if anyone has done this before!
You'll need to get the region back with
skip-template
to get the id, then query for the content, pass that back into the template and redisplay the region.Or use relationships in Runway.
Hi Drew,
I've been working on this trying to use what I think you were saying I needed to do. Can I get a hot or cold on the following:
So - in my head at least - I am calling the testimonials region and filtering through each trying to match the one that relates to the selection in the dataselect from the
Testimonials Specific
region. MyTestimonials
region contains the actual testimonials themselves and the fields and theTestimonials Specific
just contains the dataselect pulling in the name of each testimonial giver. Not sure if I am wildly off here.Is that working?
Seems to just pulling everything out. Doesn't seem to be filtering for some reason
The inner query isn't filtering?
Doesn't seem to be. I assume that was the way in which I could query against the selection made on the dataselect.
Have you tested your assumptions within the inner part?
Drew, the value passed into
$item['testimonials'] =
- What should this value be? I noticed with<perch:showall />
thattestimonials
shows up in the table blank. But I can see it pulling in things like_id
andslug
.Is
$item['slug']
what you're expecting it to be?If I run it like
I can see the output doesn't change, i.e. all still being pulled. But in the show all table, slug goes blank when slug gets used.
Can't understand why it's clearing the value
is setting
$item['slug']
to be nothing, because the'Testimonials Specific'
query is returning nothing.You need to isolate that query and get it returning something - run this all by itself:
I'm guessing that your
'filter' =>
field is wrong - is'tm_name'
used as an id in your Testimonials Specific template? Get that query working by itself, then you can use it in your bigger query.Although, I don't think you need to be using
'each'
for this...