Forum
Perch Events - Calendar
Hi guys,
I'm working with the perch_events_calendar( );
calendar, and I'm trying to output a day name for all days - including days that have no events.
Please see below:
blank-day.html
:
<span class="day no-event"><span class="day_name"><perch:events id="day" format="D" /></span><perch:events id="day" /></span>
event-day.html
:
<perch:before>
<span class="day calendar_day-event"><span class="day_name"><perch:events id="eventDateTime" format="D" /></span><perch:events id="eventDateTime" format="j" /></span>
</perch:before>
This is working fine for the event-day.html
template, but nothing comes up for the blank-day.html
template. I've tried using eventDateTime
for Blank Day, but that doesn't work - as expected.
I couldn't find anything online by search perch:events id="day"
- is anyone able to help?
Thanks, Harry
Hi Harry,
perch:events id="day"
is just a number - not a full date - so you can't get any other date information from it.Thanks for the reply, Duncan.
Is there any way to achieve what I'm looking for at all, maybe using a different id?
Also, is there a way to change the output of:
If you drop in
<perch:showall />
do any of the fields contain the date?Hi Drew, thanks for the answer!
Unfortunately not - using
<perch:showall />
on theblank-day
template doesn't show any dates, it only showsperch_page_path
,day
(which just contains the number), andperch_namespace
.So the short answer is there's nothing to help you do that.
The long answer is yes you can, but you'll need to pass the month and the year into the template from the page, and then write a template filter to piece it all back together and format into a date.
Hi Drew,
I've built out a filter that will work for this, but how do I get the current date/year that the calendar is currently displaying, and feed it through? Is there a way to do this without needing the URL to reflect the calendar?
Thanks, Harry
What do you have available on the page?
If I call
<perch:showall />
from insidecalendar.html
, it returns a field that contains theselected_month
- is there a way to feed info fromcalendar.html
intoblank-day.html
?Right, but on your page you must have more information about the date before the template is even used.
Sorry - I'm not sure I understand what you mean.
Here's the page - The calendar is a long way down: https://cargilfield.thirdfloordigital.net/default-page
The calendar is being used in a block (passed in via a
PerchSystem
variable). Nothing else on the page particularly ties into it!What is it that tells
perch_events_calendar()
to show January when the page loads? (It uses the current month/year).So when the page loads, you should be able to use the month and year from the current time and pass them as variables.
If you click on the forward or back arrows, you should have
?d=yyyy-mm
appended to the url, so in that case you would need to useperch_get('d')
to get those values.In fact, I suppose you could always use
perch_get()
and pass in a default value for situations whered
is empty (check out https://docs.grabaperch.com/functions/utilities/perch-get/)Thanks Duncan - I'm trying to do this without grabbing the URL though, I'm afraid!