yii code inside css

hi, i want users to have a feature where users can select color, font ,font size, font color etc. is it possible to write php code inside css files like




.colorpicker-saturation {







is it possibile?

Absolutely. All you have to do is to serve the CSS as a result of a controller action. With the appropriate Content-Type header, of course.

Yep, just how phtamas said. I implemented this recently for a cms project.

In my controller

public function actionLayoutCss()


    $css = $this->renderPartial('index', array(

        'css' => get my css data from db and send it to view

    ), true, false);



I extend my CController (this is not necessary, you could just do this from the controller) with that renderCss method which is simply

protected function renderCSS($data)


    header('Content-type: text/css; charset: UTF-8');

    echo $data;



And my view is a php file, so I can use data from the database, like a chosen background color.


 * My Sites Custom Layout CSS

 * <?php echo date('Y-m-d H:i:s', time()) . "\r\n"; ?>


body { background-color: <?php fetch it from db (probably passed from the controller); ?>; }

Something like that.

thanks guys