Yii 1.1: yii-body-classes

This behavior makes adding CSS body classes to your layouts quite simple
2 followers

This behavior makes adding CSS body classes to your layouts quite simple

Requirements

Yii 1.1 or above.

Usage

Unpack release in the protected/extensions/yii-body-classes folder.

Then add the behavior to a controller (or even better to your components/Controller.php):

public function behaviors() {
    return array(
        'BodyClassesBehavior' => array(
            'class' => 'ext.yii-body-classes.BodyClassesBehavior'
        ),
        ...
    );
}

In your layouts/main.php view, add to your body tag:

</head>
...
<body class="<?php echo $this->getBodyClasses(); ?>">

And you're done!

Resources

Be the first person to leave a comment

Please to leave your comment.

Create extension