LiveWhale CMS

Welcome, Guest Login

Support Center

Our documentation is moving:

Please check 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:

// 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.


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

  'title'=>'Add Body Class',

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) ...


seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found