B
B
Bags2017-06-08 08:46:52
Yii
Bags, 2017-06-08 08:46:52

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 ?>
dHlo2.png
$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', 
        ];
    }

web.php:
'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

1 answer(s)
M
Maxim Timofeev, 2017-06-08
@webinar

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 question

Ask a Question

731 491 924 answers to any question