Forum

Thread tagged as: Question, Problem, Configuration

Compare perch_item_last specific id outside of repeater

How do I get the id="date" from perch_item_last to compare with PerchSystem::set_var('today', date('Y-m-d')); outside of the repeater?

<perch:repeater id="dates" label="Courses List" scope-parent="true" order="10" max="10" >
    <perch:content id="date" type="date" label="Start Date" format="%a %e %b" />
</perch:repeater>

<perch:if id="date" match="eq" value="{today}" >
    Result
</perch:if> 

--

David Owen

David Owen 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't target items inside the repeater from outside it. Are you able to perform your check inside the repeater?

I thought that might be the case. I'll think of a way inside the repeater.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello David,

What's preventing you from performing the check inside the repeater?

Your repeater doesn't have to output anything if you don't want it to. And if you need to output the repeater content some where and perform the check some where else, you can reuse the repeater.

<perch:repeater id="dates" label="Courses List" scope-parent="true" order="10" max="10" >
    <!--* output content *-->
</perch:repeater>


<!--* markup and/or other fields *-->


<perch:repeater id="dates" label="Courses List" scope-parent="true" >
    <!--* perform your check *-->
</perch:repeater>

Of course not thinking. That'll work.