Answer the question
In order to leave comments, you need to log in
How to properly use AssetManager/ClientScript?
How to use these classes in the controller to create groups of files, which are then loaded in the view?
This is something like the minify library, where we first create groups in groupsConfig, and then pull through ?g=groupName.
I saw the minScript extension - it uses minify, but I didn’t stick it how to do it. It just did a redirect. Can you tell me how to prepare it?
If it is possible to do all this without crutches / extensions, I will be grateful for the advice.
There is nothing in the documentation, except for the description of properties/methods. Thanks, my IDE also shows ...
Answer the question
In order to leave comments, you need to log in
Yii has a CClientScript component that is responsible for including script and css files. This component has a packages property , with which we can configure the packages of our JavaScript / CSS files, specify dependencies for them, and then connect these packages in the view using one method.
Example from config:
'components' => array(
'clientScript' => array(
'packages' => array(
'item' => array(
'baseUrl' => 'js',
'js' => array('item.js'),
'depends' => array('jquery'),
),
'filter' => array(
'baseUrl' => 'js',
'js' => array('filter.js'),
'depends' => array('jquery'),
),
),
),
),
Yii::app()->clientScript->registerPackage('item');
And tell me, please, how to use scriptMap with third-party modules and extensions, just see what the script is called and make this map? And how else to add minimization (minify)?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question