Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewpattell/yii2-breadcrumbs-microdata
Add microdata for breadcrumbs yii2.
https://github.com/matthewpattell/yii2-breadcrumbs-microdata
Last synced: about 2 months ago
JSON representation
Add microdata for breadcrumbs yii2.
- Host: GitHub
- URL: https://github.com/matthewpattell/yii2-breadcrumbs-microdata
- Owner: MatthewPattell
- License: bsd-3-clause
- Created: 2016-04-07T07:53:46.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T19:17:25.000Z (9 months ago)
- Last Synced: 2024-11-10T09:40:41.301Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Microdata for breadcrumbs
=========================
Add microdata for breadcrumbs.Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist matthew-p/yii2-breadcrumbs-microdata "*"
```or add
```
"matthew-p/yii2-breadcrumbs-microdata": "*"
```to the require section of your `composer.json` file.
Usage
-----Once the extension is installed, simply use it in your code by :
Find in you project:
```php
Breadcrumbs::widget([ ... ])
```and change:
```php
use mp\bmicrodata\BreadcrumbsMicrodata; // in topBreadcrumbsMicrodata::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], // For PHP7 'links' => $this->params['breadcrumbs'] ?? []
]);
```Alternate version:
```php
Breadcrumbs::widget([
'homeLink' => BreadcrumbsUtility::getHome('Home', Yii::$app->getHomeUrl()), // Link home page with microdata
'links' => isset($this->params['breadcrumbs']) ? BreadcrumbsUtility::UseMicroData($this->params['breadcrumbs']) : [], // Get other links with microdata
'options' => [ // Set microdata for container BreadcrumbList
'class' => 'breadcrumb',
'itemscope itemtype' => 'http://schema.org/BreadcrumbList'
],
]);
```For view pages:
```php
// after set $this->title
$this->params['breadcrumbs'][] = [
'label' => 'Articles',
'url' => Url::toRoute('press-center/articles'),
];
$this->params['breadcrumbs'][] = [
'label' => $this->title,
// if there is no url element, then this is the current page.
];
```HTML result:
```html
```
That's all. Check it.