What's the proper way to work with assets in Yii? What's the proper way to work with assets in Yii? php php

What's the proper way to work with assets in Yii?


assets should be a writable directory. Yii takes care of assets.

By calling Yii::app()->assetManager->publish() some stylesheets, images, scripts, or even entire directories can be put into a web-visible folder.

pager.css and other non-familiar files are produced by widgets (CLinkPager for example) and other components (such as CClientScript publishes jQuery whenever you need that).

During deployment, this folder should be empty, but it doesn't really matter.

Adding plugins should never be done through framework folders. You can place them either in components dir and publish it runtime if necessary, or into any other convenient visible directory (like as images or css).

Update

To embed jquery.charcounter.js, put it in components directory, then call

Yii::app()->clientScript->registerScriptFile(    Yii::app()->assetManager->publish(        Yii::getPathOfAlias('application.components').'/jquery.charcounter.js'    ),    CClientScript::POS_END);

Regarding weird folder names, I firmly believe they are unique hashes (or part of), so they can be differentiated if application uses several extensions.


This would resolve the query as this provides detailed explanation for the assets folder:

http://www.yiiframework.com/wiki/148/understanding-assets/