Forum

Thread tagged as: Question

Perch Content Custom - Filter within Repeater

I have a template which creates a list of staff members.


<div class="class_staff_area"> <h2><perch:content id="teachertype" type="text" label="Staff Type Heading" required="true" title="true" /></h2> <perch:repeater id="class_staff" label="Staff Photos"> <div class="staffmemberbox <perch:content id="classnamestyle" type="select" label="Class Name" options="reception, yearone, yeartwo, yearthree, yearfour, yearfive, yearsix" allowempty="true" required="false" suppress="false"/>"> <perch:if exists="staffmember"> <a href="<perch:content id="page" type="pagelist" label="Page" />"> <span> <img src="<perch:content type="image" id="staffmember" label="staffimage" width="200" height="300" crop="true"/>" alt="teacher" /> </span></a> </perch:if> </div> </perch:repeater> </div>

Each member of staff has a class assign by perch. This work great for displaying all staff members on a staff page.

I am trying to share the content on another page but filter on the "classnamestyle" using:


<?php perch_content_custom('Staff Area', array( 'page'=>'/staff/index.php', 'template' => 'extras/classteachers_small.html', 'filter' => 'classnamestyle', 'match' => 'eq', 'value' => 'reception', ) ); ?>

But because the individual filter is within the repeater then nothing shows on the page. Is there any way I can filter on items contained within a repeater?

Richard

Richard Lowe

Richard Lowe 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use:

'filter'   => 'class_staff.classnamestyle',
Richard Lowe

Richard Lowe 0 points
Registered Developer

That kind of works but the result is that if just one of the teachers in a repeater is tagged as 'reception' it brings in all the teachers in the repeater regardless of what their 'classnamestyle' is:-

ie:- /staff/index.php:-

Class Teachers Teacher One - Reception Teacher Two - Year One

Office Staff Teacher One - No Group Teacher Two - No Group

..................................... /reception/index.php with filter:-

Reception Page

Class Teachers Teacher One - Reception Teacher Two - Year One

I hope this makes sense

Richard

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can filter items based on the content of the repeater, but you can't filter individual repeater items. Is that what you're trying to do?

Richard Lowe

Richard Lowe 0 points
Registered Developer

Yes, that's what I'm trying to do. No problem , I'll try something else.

Richard

@richard were you able to solve this? I have exactly this issue. appreciate the help.

Thanks

Hi, did somebody find a solution for this problem?

I'm working on a site for a car dealer and they want to have a central area in the backend to deal with the employees. On the contact page it should show all employees and in the specific pages for sales, rental service and the repair shop, I just want to output the specific contact person.

Thanks in advance for your ideas!

Daniel