Question

An excerpt from my

protected/config/main.php // given situation

looks like:

'modules' => array(
    'services' => array(
        'modules' => array(
            "myModule"
        )
    )
),
....
....

and for "myModule" I want to integrate a CSS-File. I could not find information about this issue in the documentation. How could I add a CSS-File on the module-level?

Something like that would be for example awesome:

'myModule' => array(
    'css-file' => array(
        'css-file-name' => css-file-path,
    ),
),
Was it helpful?

Solution 2

one must change to the module directory and find the myModuleNameModule.php file and add the following (into the function init()):

$file = Yii::getPathOfAlias('myModuleName').DIRECTORY_SEPARATOR."further_directory_structure";
$url  = Yii::app()->getAssetManager()->publish($file);
$cs   = Yii::app()->getClientScript();
$cs->registerCssFile($url);

now the css-file is reachable from all views within this module.

OTHER TIPS

You can call CClientScript to add this file in myModule.init() method:

public function init()
{
    Yii::app()->clientScript->registerCssFile($path);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top