PHP code example of matthew-p / yii2-breadcrumbs-microdata

1. Go to this page and download the library: Download matthew-p/yii2-breadcrumbs-microdata library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

matthew-p / yii2-breadcrumbs-microdata example snippets


Breadcrumbs::widget([ ... ])

use mp\bmicrodata\BreadcrumbsMicrodata; // in top

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

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

// 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.
];