« All Handlers

onCalendarDetailsFormat

The onCalendarDetailsFormat handler is called on an array of $vars containing all of the variables about to be substituted into a calendar event details view (in your theme, that’s the component lw_cal_event_details.html).

Using this handler you can overwrite existing variables, or create your own as in the example below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$_LW->REGISTERED_APPS['my_app']=[
'title'=>'My App',
'handlers'=>['onCalendarDetailsFormat'],
];

class LiveWhaleApplicationMyApp {

public function onCalendarDetailsFormat($vars) {
global $_LW;

if (!empty($vars['tags_calendar'])) {

// if event has tags, add a {related_events} variable that shows events
// which share any of those tags (excluding the current event)

$vars['related_events']=$_LW->widgetEval('<widget type="events">
<arg id="tag">'.implode('</arg><arg id="tag">', $vars['tags_calendar']).'</arg>
<arg id="tag_mode">any</arg>
<arg id="filter" name="id" action="not_equals">' . $vars['id'] . '</arg>
</widget>');
};

return $vars;
}

}
?>

The above example would be paired with the following change to the calendar component lw_cal_event_details.html. The if statement here is important, since obj.related_events might not always have a value.

1
2
3
4
5
6
{[ if (obj.related_events) { ]}
<div id="lw_cal_event_related_events">
<h3>Related Events:</h3>
{{ related_events }}
</div>
{[ } ]}