Reputation: 141
how can I use a custom CSS (obtained from a bootstrap HTML template) with yii2 framework frontend? (i'm using Yii advanced template)
things i tried and that didn't work:
frontend\assets\AppAsset.php
bootstrap-theme.css
file under frontend\web\assets\e4f17951\css\
frontend\config\main.php
according to this tutorial EDIT:
following the tutorial , i added this to main-local.php:
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => 'frontend/web',
'css' => ['css/bootstrap.css', 'css/agency.css']
],
],
],
maybe something wrong with sourcePath?
any help will be much appreciated.
Upvotes: 9
Views: 11106
Reputation: 1740
you can actually edit the AppAsset.php
file
<?php
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* Main frontend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
// add your bootstrap or any other css file path
// example
'css/bootstrap.css',
'css/agency.css',
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
// 'yii\bootstrap\BootstrapAsset', remove / comment this
// as you don't want to use default bootstrap
];
}
it should solve your issue
Upvotes: 4
Reputation: 14860
You can edit your frontend web config file to point to your custom bootstrap.css. Note that the path is relative.
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'css' => [
'bootstrap.css' => 'path/to/your/bootstrap.css'
]
]
]
],
Upvotes: 12