Forum
Can I do a conditional based on the content of another field in a template
I'm displaying diary items in Perch Runway (as a collection, not using the events app).
Each item has a start date and an end date.
I want to display differently if the start date and the end date are the same, or if they are different. i.e. if it's just one date, then just show the start date, but if they are different, then display both.
So I want something like:
<perch:content id="startdate" type="date" label="Start Date" format="d F Y" suppress="true" />
<perch:content id="enddate" type="date" label="End Date" format="d F Y" suppress="true" />
<perch:if id="startdate" match="eq" value="enddate"><perch:content id="startdate" type="date" label="Start Date" format="d F Y" /></perch:if>
Obviously, the name of the field id in "value" doesn't work. Is there any way to do this?
Alternatively, is there a way to have a date field left blank rather than defaulting to today's date, so I can do an 'if exists' check against the end date
Thanks
In your if statement, try wrapping enddate in curly brackets:
value="{enddate}"
That did it, thanks Duncan. I saw the example where curly brackets were used for variables passed into the template, it didn't occur to me to try it with the id.