Thumbnails in Calendar add-on month view
Permalink
October 06, 2016 at 10:43 AM
Hi,
I'm trying to get a thumbnail but I don't know how to get it done. I'm using the calendar add-on for C5.6 with the month view. I have a thumbnail attribute called "afbeelding_home_vierkant" which I would like to display in the <div class"event"> next to the <a> tag. I edited the code so it displays the correct dates, all other stuff is original. Can anyone help me?
<div class="ccm-calendar-grid-wrap">
<form action="<?php echo $pageBaseURL ?> " method="get">
<table class="calendar-top" cellspacing="1" cellpadding="0" border="0">
<tr>
<td style="width: 100%;">
<?php
setlocale ( LC_ALL, 'nl_NL' ) ;
echo strftime ( '%B' , $monthYearTimestamp ) ;
?>
</td>
<td style="white-space: nowrap;">
<input type="button" onclick="location.href='<?php echo $pageBaseURL ?> ?calMonth=<?php echo date ( 'n' ) ?> &calYear=<?php echo date ( 'Y' ) ?> '" value="Vandaag"/>
<select name="calMonth">
<option value="1" <?php echo ( $calMonth == 1 ) ?'selected' : '' ?> >Januari</option>
<option value="2" <?php echo ( $calMonth == 2 ) ?'selected' : '' ?> >Februari</option>
<div class="ccm-calendar-grid-wrap">
<form action="<?php echo $pageBaseURL ?> " method="get">
<table class="calendar-top" cellspacing="1" cellpadding="0" border="0">
<tr>
<td style="width: 100%;">
<?php
setlocale ( LC_ALL, 'nl_NL' ) ;
echo strftime ( '%B' , $monthYearTimestamp ) ;
?>
</td>
<td style="white-space: nowrap;">
<input type="button" onclick="location.href='<?php echo $pageBaseURL ?> ?calMonth=<?php echo date ( 'n' ) ?> &calYear=<?php echo date ( 'Y' ) ?> '" value="Vandaag"/>
<select name="calMonth">
<option value="1" <?php echo ( $calMonth == 1 ) ?'selected' : '' ?> >Januari</option>
<option value="2" <?php echo ( $calMonth == 2 ) ?'selected' : '' ?> >Februari</option>
<option value="3" <?php echo ( $calMonth == 3 ) ?'selected' : '' ?> >maart</option>
<option value="4" <?php echo ( $calMonth == 4 ) ?'selected' : '' ?> >April</option>
<option value="5" <?php echo ( $calMonth == 5 ) ?'selected' : '' ?> >Mei</option>
<option value="6" <?php echo ( $calMonth == 6 ) ?'selected' : '' ?> >Juni</option>
<option value="7" <?php echo ( $calMonth == 7 ) ?'selected' : '' ?> >Juli</option>
<option value="8" <?php echo ( $calMonth == 8 ) ?'selected' : '' ?> >Augustus</option>
<option value="9" <?php echo ( $calMonth == 9 ) ?'selected' : '' ?> >September</option>
<option value="10" <?php echo ( $calMonth == 10 ) ?'selected' : '' ?> >Oktober</option>
<option value="11" <?php echo ( $calMonth == 11 ) ?'selected' : '' ?> >November</option>
<option value="12" <?php echo ( $calMonth == 12 ) ?'selected' : '' ?> >December</option>
</select>
<select name="calYear">
<?php for ( $i = $calYear - 1 ; $i <= $calYear + 6 ; $i ++ ) { ?>
<option value="<?php echo $i ?> " <?php echo ( $calYear == $i ) ?'selected' : '' ?> ><?php echo $i ?> </option>
<?php } ?>
</select>
<input type="submit" value="Ga"/>
<input type="button" onclick="location.href='<?php echo $pageBaseURL ?> ?calMonth=<?php echo ( $calMonth - 1 > 0 ) ?$calMonth - 1 : 12 ?> &calYear=<?php echo ( $calMonth - 1 > 0 ) ?$calYear : $calYear - 1 ?> '" value="<<" />
<input type="button" onclick="location.href='<?php echo $pageBaseURL ?> ?calMonth=<?php echo ( $calMonth + 1 <= 12 ) ?$calMonth + 1 : 1 ?> &calYear=<?php echo ( $calMonth + 1 <= 12 ) ?$calYear : $calYear + 1 ?> '" value=">>" />
</td>
</tr>
</table>
</form>
<div class="ccm-calendar-grid-table-wrap">
<div class="tr"></div><div class="tl"></div>
<table class="ccm-calendar-grid" style="width:100%">
<tr class="header">
<td width="14%">Zondag</td>
<td width="14%">Maandag</td>
<td width="14%">Dinsdag</td>
<td width="14%">Woensdag</td>
<td width="14%">Donderdag</td>
<td width="14%">Vrijdag</td>
<td width="14%">Zaterdag</td>
</tr>
<tr>
<?php
$maxCellEvents = CalendarEvent:: GRID_MAX_EVENTS ;
$daysInMonth = date ( 't' , $monthYearTimestamp ) ;
$firstDayInMonthNum = date ( 'N' , $monthYearTimestamp ) ;
if ( $firstDayInMonthNum == 7 ) $firstDayInMonthNum = 0 ;
$cols = 0 ;
$cellCounter = 0 ;
Loader:: helper ( 'text' ) ;
for ( $i = ( $firstDayInMonthNum *- 1 ) + 1 ; $i <= $daysInMonth ; $i ++ ) {
$cellCounter ++;
if ( $cols >= 7 ) {
echo '</tr><tr>' ;
$cols = 0 ;
}
$cols ++;
$dateKey = $calMonth . '_' . $i . '_' . $calYear ;
$numberOfEvents = ( is_array ( $eventObjsByDate [ $dateKey ] ) ) ?count ( $eventObjsByDate [ $dateKey ] ) : 0 ;
$hasEvents = ( $numberOfEvents > 0 ) ?1 : 0 ;
// set the sort order of the events for the current day
if ( $hasEvents ) {
// loop through and make the events know what day their being displayed on
foreach ( $eventObjsByDate [ $dateKey ] as $key => $event ) {
if ( $event instanceof CalendarEvent) {
$eventObjsByDate [ $dateKey ] [ $key ] -> setComparisonDayTimestamp ( strtotime ( $calMonth . '/' . $i . '/' . $calYear ) ) ;
}
}
usort ( $eventObjsByDate [ $dateKey ] , array ( 'CalendarEvent' , 'compareTimeOfDay' ) ) ;
}
$isToday = date ( 'n_j_Y' ) == $dateKey ;
?>
<td class="<?php if ( $isToday ) { ?> ccm-calendar-today<?php } ?> ">
<div class="ccm-calendar-date-wrap <?php if ( $i > 0 && $canAddEvent ) { ?> ccm-calendar-cell-add-event <?php } ?> " ccm-calendar-cell-date="<?php echo $calMonth . '/' . sprintf ( '%02d' , $i ) . '/' . $calYear ?> ">
<?php if ( $i > 0 ) { ?>
<div class="ccm-calendar-date"><?php echo $i ?> </div>
<?php } else { ?>
<div class="ccm-calendar-date-inactive"> </div>
<?php } ?>
<div class="minHeight"></div>
<div class="ccm-calendar-events nonPopup">
<?php if ( $hasEvents ) {
$eventsShown = 0 ;
foreach ( $eventObjsByDate [ $dateKey ] as $eventObj ) { ?>
<div class="ccm-calendar-event <?php echo ( $eventsShown % 2 ?"ccm-calendar-event-odd" : "" ) ?> ">
<a href="<?php echo View:: url ( $eventObj -> getCollectionPath ( ) ) ?> "><?php echo $eventObj -> getCollectionName ( ) ?> </a>
</div>
<?php $eventsShown ++;
if ( is_int ( $maxCellEvents ) && intval ( $maxCellEvents ) > 0 && $eventsShown >= $maxCellEvents ) break ;
}
}
?>
</div>
<div class="spacer"></div>
<?php if ( $hasEvents && $numberOfEvents > $maxCellEvents ) { ?>
<div class="ccm-calendar-events-more">
<a id="calPopupTrigger<?php echo $i ?> " class="ccm-calendar-popup-trigger">+ <?php echo $numberOfEvents - intval ( $maxCellEvents ) ?> more</a>
<div style="z-index:6; float:left">
<div id="calPopup<?php echo $i ?> " class="ccm-calendar-popup" style="z-index:10">
<div class="events">
<?php $more_i = 0 ;
foreach ( $eventObjsByDate [ $dateKey ] as $eventObj ) { ?>
<div class="event <?php echo ( $more_i % 2 ?"event-odd" : "" ) ; ?> "><a href="<?php echo View:: url ( $eventObj -> getCollectionPath ( ) ) ?> "><?php echo $eventObj -> getCollectionName ( ) ?> </a></div>
<?php
$more_i ++;
} ?>
<div class="spacer"></div>
</div>
<div class="b"></div>
<div class="spacer"></div>
</div>
</div>
</div>
<?php } ?>
<div class="spacer"></div>
</div>
</td>
<?php }
while ( $cols < 7 ) {
echo '<td><div class="ccm-calendar-date-inactive"> </div></td>' ;
$cols ++;
}
?>
</tr>
</table>
<div class="br"></div><div class="bl"></div>
</div>
</div>
<?php if ( $canAddEvent ) {
Loader:: packageElement ( 'add_event_overlay' , 'calendar' ) ;
}