I'm currently using the Calendar module in Drupal 7 and wish to add a wrapper with a class around the entries on days that have entries.
I've attempted to do this in the various template files and have been testing variables available with print_r for the last hour or so.
The a quick print_r in calendar-month-col.tpl.php provides the following arrays, either an empty day:
Array
(
[entry] => <div class="month day"> 2 </div>
[colspan] => 1
[rowspan] => 1
[class] => date-box future empty
[date] => 2015-05-02
[id] => events-2015-05-02-date-box
[header_id] => Saturday
[day_of_month] => 2
)
or a day with an event:
Array
(
[entry] => <div class="item">
<div class="view-item view-item-events">
<div class="calendar monthview">
<div class="calendar.1.field_date_time.0.0 contents">
<a href="/node/1/edit?destination=node/6">edit</a>
<a href="/residents/events/test-event">Test Event</a> </div>
<div class="cutoff"> </div>
</div>
</div>
</div><div class="item">
<div class="view-item view-item-events">
<div class="calendar monthview">
<div class="calendar.42.field_date_time.0.0 contents">
<a href="/node/42/edit?destination=node/6">edit</a>
<a href="/residents/events/test-event-2">Test Event 2</a> </div>
<div class="cutoff"> </div>
</div>
</div>
</div>
[colspan] => 1
[rowspan] => 1
[class] => single-day future
[date] => 2015-04-30
[id] => events-2015-04-30-0
[header_id] => Thursday
[day_of_month] => 30
)
I've considered checking for an existing string (empty days have the class "empty" or "no-entry")
Any suggestions?
Edit: For the time being, I've put a quick solution together that will let me style the Calendar as needed.
$strings = array('empty','no-entry');
foreach($strings as $string):
if (strpos($item['class'],$string)!==false):
$addstring = "";
break;
else :
$addstring = "event ";
endif;
endforeach;
It's not nearly as clean as I would like, but it works.
Edit: Added !== false to strpos.
As a side note, I ended up simply css'ing out the date-box row.