Answer the question
In order to leave comments, you need to log in
How to set default styles path in yii2?
Styles in views are not connected:
this path is not visible. Have to add .
How to fix it?
The structure of the application is as follows:
In the view I connect:
AppAsset:<link href="/css/1.css" rel="stylesheet">
= $asset->baseUrl
$asset = app\assets\AppAsset::register($this);
class AppAsset extends \yii\web\AssetBundle
{
public $sourcePath = '@app/media2/';
public $css = [
'css/1.css',
'css/theme-4-bootstrap.css',
'css/vendor.css',
'css/theme-4.css',
'css/demo.css',
'css/custom.css'
];
...................
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
'yii\web\YiiAsset',
];
}
'assetManager' => [
// uncomment the following line if you want to auto update your assets (unix hosting only)
//'linkAssets' => true,
'forceCopy' => true, //перезапись файлов стилей
Answer the question
In order to leave comments, you need to log in
And what is it <link href="/css/1.css" rel="stylesheet">
?
AssetsManager creates an assets folder in the root of the site and puts all the files there, at the same time it forms the url and writes the link in the header.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question