Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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 top

BreadcrumbsMicrodata::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.