andrewdanilov / yii2-breadcrumbs
Breadcrumbs widget
Installs: 41
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.6.0
- yiisoft/yii2: ~2.0.0
README
Widget let you create breadcrumbs in simialar way as the default yii breadcrumbs widget, but with help of template files. You can define templates separetely for wrapper, link item and for active (last) breadcrumb item.
Installation
The preferred way to install this extension is through composer.
Either run
composer require andrewdanilov/yii2-breadcrumbs "~1.0.0"
or add
"andrewdanilov/yii2-breadcrumbs": "~1.0.0"
to the require
section of your composer.json
file.
Usage
<?= andrewdanilov\breadcrumbs\Breadcrumbs::widget([ 'templateWrapper' => '@frontend/views/site/breadcrumbs/wrapper', // optional 'templateItem' => '@frontend/views/site/breadcrumbs/item', // optional 'templateActiveItem' => '@frontend/views/site/breadcrumbs/active-item', // optional 'showHome' => false, // optional, default true 'homeLabel' => 'Main', // optional, default 'Main' 'homeUrl' => ['site/index'], // optional, default ['/'] 'showActiveItemUrl' => true, // optional, default false 'hideIfSingleItem' => false, // optional, default true. Hides widget if the only element presents in items array. If showHome is true, then home page counts as first element. 'microdata' => true, // optional, default false 'items' => [ ['label' => 'Category', 'url' => ['site/category']], ['label' => 'Subcategory', 'url' => ['site/subcategory']], 'Product #1', // short form of ['label' => 'Product #1'] ], ]) ?>
You can use own templates for breadcrumbs wrapper element, list items and active list item. Just copy example templates from /vendor/andrewdanilov/yii2-breadcrumbs/views to your prefered directory. Modify them as you need and define correspond paths to their location: templateWrapper
, templateItem
, templateActiveItem
.
You can enable schema.org microdata for breadcrumbs by setting microdata
option to true.