With this extension, you can use Less CSS files with registerCSSFile.
The code is based on zsoltlengyelits, LessCSS-for-Yii extension. I've updated it so,
- it uses the assetsfolder defined by CAssetmanager
- You have a global caching setting, instead of per file
- Updated to the latest lessc parser which includes a compress css feature
- It uses CClientscript to register the outputted css automatically
Yii 1.1 or above
Copy the folder to your extension folder (protected/extensions).
'components' => array( 'clientScript' => array( 'class' => 'ext.LessClientscript.LClientscript', 'caching' => true, //use the cached css file if available 'compress' => false, //remove whitespace and linearize to 1 line ) );
Now you can add it in your view or controller:
- Store temporary less file in runtime folder
- Fixed bug where if you provided a file with no css in it, it could not find the assets file
- Better commenting
- Return clientscript object for chaining
incorrect parsing of paths
I think some urls are not correctly parsed, for example:
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl.'/css/bootstrap.min.css'); ?>
@kmindi Hi sorry to hear that. I ran some tests, but it works fine here:
Make sure your theme folder exists (/themes/classic)
And your config is correct:
My file structure is like this:
LClientscript: Less stylesheet not found
LClientscript: Less stylesheet not found: /srv/http/nginx/html/my/web//my/web/themes/theme/less/ta.less
Do you see the double slash?, Am I doing something wrong?:
(Its working if i specify a css file)
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl.'/less/ta.less'); ?>
Sorry I don't have a nginx server to test this. Could you try something for me?
In LClientscript.php change the
not fixing it
That does not correct it...
I think the problem is the following:
gives me /my/web/themes/mytheme/less/ta.less
gives me /srv/http/nginx/html/my/web/
so the paths overlap a bit...
According to Yii documentation (http://www.yiiframework.com/doc/guide/1.1/en/topics.theming)
The theme directory should point out to Webroot/themes (or in other words: Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'themes')
So it's weird there's overlap. Could you try
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.