php - How to use custom css file for layout of a module in Yii2 -


i using basic pack of yii2. created module named admin , want module has own layout. don't know put css files. then, how include them in layout.php.

my directory structure:

basic -- module   -- admin     -- controllers        -- defaultcontroller.php     -- views        -- default        -- layouts           -- main.php           -- css              -- style.css 

in main.php, use code, doesn't work:

<?php $this->registerlinktag([     'rel'  => 'stylesheet',     'href' => 'css/style.css', ]); $this->head(); ?> 

create custom asset bundle file:

frontend/module/admin/assets/adminasset.php   

init $sourcepath , $css variables:

public $sourcepath = '@app/module/admin/web'; public $css = ['css/admin.css']; // path admin.css file : $sourcepath/css/admin.css 

register adminasset bundle (in layout, view, etc.):

use frontend\module\admin\assets\adminasset;     adminasset::register($this); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -