문제

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,
    ),
),
도움이 되었습니까?

해결책 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.

다른 팁

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

public function init()
{
    Yii::app()->clientScript->registerCssFile($path);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top