For example, breadcrumbs like "Home / Sample Post / Edit" means the user is viewing an edit page for the "Sample Post". He can click on "Sample Post" to view that page, or he can click on "Home" to return to the homepage. To use Breadcrumbs, you need to configure its $links property (inherited from yii\widgets\Breadcrumbs) , which specifies the links to be displayed. For example, php $this is the view object currently being used echo Breadcrumbs::widget([ 'itemTemplate' => "{link}\n", // template for all links 'links' => [ [ 'label' => 'Post Category', 'url' => ['post-category/view', 'id' => 10], 'template' => "{link}\n", // template for this link only ], ['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]], 'Edit', ], ]); Because breadcrumbs usually appear in nearly every page of a website, you may consider placing it in a layout view. You can use a view parameter (e.g. $this->params['breadcrumbs']) to configure the links in different views. In the layout view, you assign this view parameter to the $links property like the following: php $this is the view object currently being used echo Breadcrumbs::widget([ 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], ]);
See also: [yii\widgets\Breadcrumbs](http://www.yiiframework.com/doc-2.0/yii-widgets-breadcrumbs.html)
Author: Christoph Erdmann (yii2-materializecss@pluspunkt-coding.de)
Inheritance: extends yii\widgets\Breadcrumbs
Beispiel #1
0
$menuItems = [['label' => 'Home', 'url' => ['/site/index']], ['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>' . Html::beginForm(['/site/logout'], 'post') . Html::submitButton('Logout (' . Yii::$app->user->identity->username . ')', ['class' => 'btn btn-flat']) . Html::endForm() . '</li>';
}
echo Nav::widget(['options' => ['class' => 'right'], 'items' => $menuItems]);
NavBar::end();
?>
        </header>

        <main class="content">
            <div class="container">
                <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>

                <?php 
echo Alert::widget();
?>

                <?php 
echo $content;
?>
            </div>
        </main>

        <footer class="footer page-footer">
            <div class="container">
                <div class="row">