« All Handlers

onBeforeSync

This handler fires immediately before an item is created or updated that originates from a synced source. (At present, $type may only be ‘events’.) This will let you do things like filter or modify the feed values before they’re imported into LiveWhale. An example module is below.

Parameter Description
$type currently only works for $type = “events”
$subscription_id id of the linked calendar
$buffer array of the feed item values
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
<?php
$_LW->REGISTERED_APPS['my_app']=array(
'title'=>'My App',
'handlers'=>array('onBeforeSync'),
);

class LiveWhaleApplicationMyApp {

// perform additional form validations
public function onBeforeSync($type, $subscription_id, $buffer) {
global $_LW;

if ($type == 'events') {

// example processing of a feed $buffer:
if (strpos(@$_LW->linked_calendar_url, '://www.my-athletics-website.com/')!==false) { // if this is an Athletics feed
if (stripos($buffer['title'], '(My School) ') === 0) { // remove the first 12 characters if they are "(My School) "
$buffer['title'] = substr($buffer['title'], 12);
};
};

}

return $buffer;
}
}
?>