LiveWhale CMS

Welcome, Guest Login

Support Center

Our documentation is moving: docs.livewhale.com

Please check docs.livewhale.com for the most up-to-date LiveWhale CMS and LiveWhale Calendar documentation. The below legacy documentation will remain available as a reference until the documentation migration is complete.

Dynamically Adding Body Classes

Last Updated: Jun 25, 2014 01:45PM PDT

LiveWhale already adds several body classes to every page dynamically at the time of output, such as group_[attribute_safe_public_group_name]. For convenience, you can add additional body classes programmatically. The method in question is:

$_LW->appendBodyClass('class_name');
// class_name is the CSS class you wish to apply

You can add the body class in any handler prior to, but not including onOutput, as the page has already been output by that point. Unless your logic requires otherwise, the recommended handlers for utilizing this method are onLoad or onBeforeOutput.

<?php

// file: client/modules/add_body_class/public.application.add_body_class.php

$_LW->REGISTERED_APPS['add_body_class']=array(
  'title'=>'Add Body Class',
  'handlers'=>array('onLoad'),
);

class LiveWhaleApplicationAddBodyClass {

  public function onLoad() { // runs when this application module is loaded
    global $_LW;
    // some conditional logic that dictates when to add the body class
    // such as if(strpos($_SERVER['REQUEST_URI'], '/path/to/begin/with') === 0) ...
    $_LW->appendBodyClass('my_body_class');
  }

}

?>
eb8f96c071020d8b0923da726d6cab65@livewhale.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete?b_id=4256