andrewdanilov/yii2-breadcrumbs

面包屑小部件

安装: 40

依赖项: 0

建议者: 0

安全性: 0

星标: 1

观察者: 2

分支: 1

公开问题: 0

类型:yii2-extension

1.0.4 2024-01-15 22:30 UTC

This package is auto-updated.

Last update: 2024-09-16 00:04:28 UTC


README

小部件允许您以类似于默认的yii面包屑小部件的方式创建面包屑,但使用模板文件。您可以分别定义包装器、链接项和活动(最后一个)面包屑项的模板。

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一:

composer require andrewdanilov/yii2-breadcrumbs "~1.0.0"

"andrewdanilov/yii2-breadcrumbs": "~1.0.0"

将以下内容添加到您的 composer.json 文件的 require 部分:

使用方法

<?= 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']
	],
]) ?>

您可以为面包屑的 包装器 元素、列表项活动列表项 使用自己的模板。只需将示例模板从 /vendor/andrewdanilov/yii2-breadcrumbs/views 复制到您首选的目录。根据需要修改它们,并定义它们的路径:templateWrappertemplateItemtemplateActiveItem

您可以通过将 microdata 选项设置为 true 来为面包屑启用 schema.org 微数据。