Forum
Custom fields in events: how to output categories and current month
Using Events (in Runway). Have created some custom fields including categories. Tried a few different ways to output the selected categories but can't make it work. This is the code in my listing html file:
<perch:before></perch:before>
<div style="padding-left: 12px;"><perch:events id="eventDateTime" format="H:i" />
<a href="<perch:events id="eventURL" />"><perch:events id="eventTitle" /></a>
<br />Event Desc: <perch:events id="eventDescHTML" />
<br />Setting: <perch:events id="setting" /> <!-- custom field displays as expected -->
<br />Service category: <perch:category id="Service" />
<br />Choir category: <perch:category id="Choir" />
<br />Month: <perch:events id="current_month" />
</div>
<perch:after></perch:after>
And current_month returns nothing. What syntax should I use for this? John
You're missing the
<perch:categories>
tag pair.I've added the tag pair (two instances) but still nothing. I'm expecting/hoping to display one or more (or none) categories selected via the template when the event was created or edited.
Which template is this in?
I have a global layout item which includes this perch_events_custom code
The template code in the reply above is listing/banner-listing.html
The template events>event.html looks like this
Does the editing of the categories work as expected?
I have five sets of categories all populated through the categories app. I've opted to display them as a dropdown list. I can select one or more of them and the selections are shown in the field on the edit event details page. The selected categories are show greyed out in the dropdown lists.
Debug shows:
Ok, great. What does your output template look like?
This is the page (still in development).
perch_layout('global/topimages') is html and includes this php
~~~~ <?php
?>
<perch:before></perch:before> <div style="padding-left: 12px;"><perch:events id="eventDateTime" format="H:i" /> <a href="<perch:events id="eventURL" />"><perch:events id="eventTitle" /></a> <br />Event Desc: <perch:events id="eventDescHTML" /> <br />Setting: <perch:events id="setting" /> <!-- custom field displays as expected -->
<perch:after></perch:after> ~~~
I think this:
should be:
That's it. Thank you Drew. Should I raise a separate thread about current_month; I can't get it to display. John
Where are you setting
current_month
?I'm not; and that will be why! I assumed
current_month
would be available since I was displaying an event. How do I do this?What are you expecting it to be - the month of the event or the current month based on the current time?
Should have been clear: month of the event.
Should be:
See here for all the formatting options: https://php.net/manual/en/function.date.php
Brilliant; thank you.