Hey there,
I’m trying to work with @bastianallgeier’s calendar plugin and got a little bit lost. Any help would be highly appreciated !
The calendar will have maximum of one post per day, but not every day will have posts. The days that don’t have posts can get the same class inactive
to keep the day structure. I attached a sketch from the design for visual reference.
— The first thing I’m trying to do is some sort of if / foreach
that checks if there are posts in the month and if so, display a new month on the page (if posts in July > show July month. If no posts in the month > don’t show). Each new month will go on top (flip() somehow?).
— The second thing I’m trying to do is when hover a date to change the background of the page with an image from that day post. A little bit lost how to fetch the data from the custom field in panel. I’m getting contents using something like this:
<?php foreach($page->children()->filterBy('template', 'calendar')->children() as $item): ?>
<?php echo $item->featuredimage() ?>
<?php endforeach ?>
This is the snippet I’m using:
<?php
date_default_timezone_set('UTC');
setlocale(LC_ALL, 'en_US');
$residencyyear = $page->year()->int();
$month = filter_input(INPUT_GET, 'month', FILTER_VALIDATE_INT);
$calendar = new calendar();
$currentMonth = $calendar->month($residencyyear, $month);
?>
<div class="calendar-wrapper">
<div class="month-wrapper">
<div class="month-container">
<div class="border month times"><?php echo $currentMonth->name() ?>, <?php echo $residencyyear ?></div>
</div>
<?php foreach($currentMonth->weeks(6) as $week): ?>
<div class="month-container">
<?php foreach($week->days() as $day): ?>
<div data-timestamp="<?php echo $residencyyear ?>" class="day<?php if($day->month() != $currentMonth) echo ' inactive' ?>"><?php echo $day->int() ?></div>
<?php endforeach ?>
</div>
<?php endforeach ?>
</div>
</div>
this is the result I’m trying to achieve as sketch. Green block would be the background image.