Answer the question
In order to leave comments, you need to log in
Yii2 and bootstrap 4, how to upgrade yiisoft/yii2-bootstrap components to bootstrap4?
I register in composer.json
"yiisoft/yii2-bootstrap": "[email protected]",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"bower-asset/bootstrap": "4.0.0",
"bower-asset/font-awesome": "4.*",
- Updating bower-asset/bootstrap (v3.3.7 => v4.0.0): Downloading (100%)
- Updating yiisoft/yii2-bootstrap (2.0.8 => 2.0.0-beta): Downloading (100%)
Answer the question
In order to leave comments, you need to log in
Connect the extension via composer:
Then in assets add
class AppAsset extends AssetBundle
{
public $depends = [
'yii\web\YiiAsset',
'grozzzny\depends\bootstrap4\Bootstrap4Asset',
'grozzzny\depends\bootstrap4\Bootstrap4PluginAsset',
];
}
class Bootstrap4Asset extends AssetBundle
{
public $sourcePath = '@vendor/twbs/bootstrap/dist';
public $css = [
'css/bootstrap.css',
];
public function init()
{
parent::init(); // TODO: Change the autogenerated stub
Yii::$app->view->on(View::EVENT_AFTER_RENDER, function (){
unset(Yii::$app->view->assetBundles['yii\bootstrap\BootstrapAsset']);
});
Yii::$app->view->on(View::EVENT_BEGIN_BODY, function (){
unset(Yii::$app->view->assetBundles['yii\bootstrap\BootstrapAsset']);
});
}
}
<?= Nav::widget([
'options' => ['class' => 'navbar-nav d-flex justify-content-between w-100'],
'items' => [
[
'label' => ''Услуги,
'options' => ['class' => 'nav-item'],
'linkOptions' => ['class' => 'nav-link'],
'url' => ['services'],
'active' => Yii::$app->controller->id == 'services'
],
....
[
'label' => 'Контакты',
'options' => ['class' => 'nav-item'],
'linkOptions' => ['class' => 'nav-link'],
'active' => Yii::$app->controller->id == 'contacts',
'url' => ['/contacts']
]
]
]);?>
<nav aria-label="breadcrumb" class="mb-3">
<?= Breadcrumbs::widget([
'links' => $this->params['breadcrumbs'],
'options' => ['class' => 'breadcrumb'],
'tag' => 'ol',
'itemTemplate' => "<li class='breadcrumb-item'>{link}</li>\n",
'activeItemTemplate' => "<li class=\"breadcrumb-item active\" aria-current=\"page\">{link}</li>\n",
])?>
</nav>
<nav aria-label="Page navigation">
<?= LinkPager::widget([
'pagination' => $provider->pagination,
'linkContainerOptions' => ['class' => 'page-item'],
'linkOptions' => ['class' => 'page-link'],
'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link']
]) ?>
</nav>
<?= Alert::widget([
'options' => ['class' => 'alert alert-danger show', 'role' => 'alert'],
'body' => $message,
]) ?>
class AppAsset extends AssetBundle
{
public $depends = [
..
//Material Design for Bootstrap 4
'grozzzny\depends\mdbootstrap\MDBootstrapAsset',
'grozzzny\depends\mdbootstrap\MDBootstrapPluginAsset',
..
];
}
'assetManager' => [
'bundles' => [
// Если решили переопределить scss:
'grozzzny\depends\mdbootstrap\MDBootstrapAsset' => [
'basePath' => '@webroot',
'baseUrl' => '@web',
'css' => ['css/mdbootstrap/mdb.css'],
],
// Если решили подключить доступные модули в коллекции MDB:
'grozzzny\depends\mdbootstrap\MDBootstrapPluginAsset' => [
'chart' => true,
'enhancedModals' => true,
'formsFree' => true,
'jqueryEasing' => true,
'scrollingNavbar' => true,
'velocity' => true,
'waves' => true,
'wow' => true,
],
],
],
yiisoft/yii2-bootstrap - not designed for the 4th bootstrap in principle. So don't even try it yet.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question