Yii component to register your assets in one place.
Requirements ¶
Requirements of using this extension (e.g. Yii 1.1 or above)
Usage ¶
- Place AssetsRegistryComponent.php into components
- In layout
<?php app()->AssetsRegistry; ?>
- In config/main.php
'components' => array(
'AssetsRegistry' => array(
'class' => 'AssetsRegistryComponent',
/* path to your config file (default config.assetsregistry) */
'config' =>'application.config.assetsregistry'
),
- Example of config file
return array(
'layout' => array(
'js' => array(
array('files' => array('test'), //js files
'url' => 'js',
'pos' => CClientScript::POS_HEAD
),
),
'css' => array()
),
'users/view' => array(
'js' => array(
array('files' => array('test2', 'test3'),
'url' => 'js',
'pos' => CClientScript::POS_HEAD
),
/* example with another position */
array('files' => array('test2', 'test3'),
'url' => 'js',
'pos' => CClientScript::POS_END
),
),
'css' => array(
array('files' => array('test'),
'url' => 'css',
'addBaseUrl' => true),
)
),
);
Resources ¶
Dependency from globals.php (YiiBoilerplate)
Please, leave your suggestions in the comments
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.