2017 © Pedro Peláez
 

yii2-extension yii2-breadcrumbs-microdata

Add microdata for breadcrumbs.

image

matthew-p/yii2-breadcrumbs-microdata

Add microdata for breadcrumbs.

  • Sunday, March 19, 2017
  • by hellboymxb@gmail.com
  • Repository
  • 0 Watchers
  • 1 Stars
  • 1,320 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

Microdata for breadcrumbs

Add microdata for breadcrumbs., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist matthew-p/yii2-breadcrumbs-microdata "*"

or add, (*4)

"matthew-p/yii2-breadcrumbs-microdata": "*"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by :, (*6)

Find in you project:, (*7)

Breadcrumbs::widget([ ... ])

and change:, (*8)

use mp\bmicrodata\BreadcrumbsMicrodata; // in top

BreadcrumbsMicrodata::widget([
    'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], // For PHP7 'links' => $this->params['breadcrumbs'] ?? [] 
]);

Alternate version:, (*9)

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:, (*10)

// 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:, (*11)

<ul itemscope="" itemtype="http://schema.org/BreadcrumbList">
    <li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
        <a href="/" itemprop="item">
            <span itemprop="name">Home page</span>
        </a>
        <meta itemprop="position" content="1">
    </li>
    <li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
        <a href="/press-center/articles" itemprop="item">
            <span itemprop="name">Articles</span>
        </a>
        <meta itemprop="position" content="2">
    </li>
    <li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem" class="text-light" style="opacity: 0.65;">
        <span itemprop="name">10 Must-Read Books for Programmers</span>
        <meta itemprop="position" content="3">
    </li>
</ul>

That's all. Check it., (*12)

The Versions

19/03 2017

dev-master

9999999-dev

Add microdata for breadcrumbs.

  Sources   Download

BSD-3-Clause

The Requires

 

by Matthew Patell

extension yii2 breadcrumbs microdata

19/03 2017

1.0

1.0.0.0

Add microdata for breadcrumbs.

  Sources   Download

BSD-3-Clause

The Requires

 

by Matthew Patell

extension yii2 breadcrumbs microdata