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.
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'
]
]
]
],
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With