« All Handlers

onBeforeOutput

The onBeforeOutput handler works very similarly to the onOutput handler, except that it is run before widgets have been processed (i.e., they still appears as <widget id="... in the $buffer).

Furthermore, as the below example indicates, REGISTERED_BODY_CLASSES haven’t yet been added to the page HTML, so you can still edit that array.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$_LW->REGISTERED_APPS['my_app']=array(
'title'=>'My App',
'handlers'=>array('onBeforeOutput'),
);

class LiveWhaleApplicationMyApp {

public function onBeforeOutput($buffer) {
global $_LW;

// add page_id_123 to the body class
$_LW->applyPageAndGroupVars('<xphp var="page_id"/>');
if (!empty($GLOBALS['page_id'])) {
$_LW->REGISTERED_BODY_CLASSES[]='page_id_'.$GLOBALS['page_id'];
};
return $buffer;

}

}
?>