Answer the question
In order to leave comments, you need to log in
Has anyone seen a good article or video on creating modules?
Friends, tell me, please.
I understand with yii2. There was a necessity to write the module.
My actions:
1) I made a module through gii.
2) As a result, I have 3 folders (controllers, models, views) and the file itself in the root module.php with init.
3) I now need to add css, js files.
4) Created an assets folder in the module root and 2 css, js folders with files inside.
Now I can't find how to connect them. It seems like you need to create another moduleAsset.php file in the root folder of the module and connect everything in it. But there is a hitch and I don’t understand how to proceed.
Answer the question
In order to leave comments, you need to log in
first you need to create a set of resources that will describe what files you need to include and where to get them from. You can place it in the root of the module, and describe it like this:
class MyAsset extends \yii\web\AssetBundle
{
public $js = [
'js/file1.js'
];
public $css = [
'css/file1.css'
];
public function init()
{
$this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'assets';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question