PHP code example of digitv / yii2bootstrap4
1. Go to this page and download the library: Download digitv/yii2bootstrap4 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitv / yii2bootstrap4 example snippets
<?= digitv\bootstrap\widgets\Progress::widget(['percent' => 60, 'label' => 'Test label'])
//Breadcrumbs in layout view
<?= digitv\bootstrap\widgets\Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
])
//Navbar in layout view
digitv\bootstrap\widgets\NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-dark bg-dark navbar-expand-lg fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'Dropdown', 'url' => ['/site/index'], 'items' => [
['label' => 'First', 'url' => ['/site/index']],
['label' => 'Second', 'url' => '/'],
]],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = '<li>'
. digitv\bootstrap\Html::beginForm(['/site/logout'], 'post')
. digitv\bootstrap\Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. digitv\bootstrap\Html::endForm()
. '</li>';
}
echo digitv\bootstrap\widgets\Nav::widget([
'options' => ['class' => 'navbar-nav ml-auto'],
'items' => $menuItems,
]);
digitv\bootstrap\widgets\NavBar::end();