PHP Classes

How to Implement a Breadcrumbs PHP Solution in Web Page Action Controllers usingYii2 Metacrumbs: Generate breadcrumbs for navigating between pages

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 13 All time: 11,461 This week: 524Up
Version License PHP version Categories
yii2-metacrumbs 1.0MIT/X Consortium ...5PHP 5, Graphics, Design Patterns
Description 

Author

This package can generate breadcrumbs for navigating between pages.

It provides classes that define the structure of breadcrumbs to navigate between pages generated using controller classes of MVC applications that use the YII framework.

The package also provides classes that can generate meta-tags that define a property of the pages like titles, descriptions, images, etc...

Picture of Insolita
  Performance   Level  
Innovation award
Innovation award
Nominee: 18x

 

Documentation

Yii2 meta-crumbs pack

alternative way for work with breadcrumbs and metadata with open-graph-protocol helpers

also include NoLayoutBehavior for registration actions where layout must be skipped

Status Latest Stable Version Total Downloads License

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist insolita/yii2-metacrumbs "~2.0"

or add

"insolita/yii2-metacrumbs": "~1.0"

to the require section of your composer.json file.

Usage

- register MetaCrumbsBootstrap, or manual register as singleton :

 \Yii::$container->setSingleton(IBreadcrumbCollection::class,BreadCrumbs::class);

and/or

 \Yii::$container->setSingleton(IMetaManager::class,MetaManager::class);

- add widget in layout

       <?= \insolita\metacrumbs\widgets\CrumbWidget::widget([]) ?>

- add CrumbedControllerTrait in base controller (or in needed controllers) and register crumbs - add MetaManagerTrait in needed controllers or base controller (also in service possible)

Controller Example

 class ExampleController extends Controller
 {
     use CrumbedControllerTrait;
     use MetaManagerTrait;

     public function actions()
     {
         return [
             'error'   => [
                 'class' => 'yii\web\ErrorAction',
             ],
         ];
     }

    public function behaviors()
    {
        return [
            'nolayout'=>['class'=>NoLayoutBehavior::class,'actions' => ['ajax']]
            // 'nolayout'=>['class'=>NoLayoutBehavior::class,'actions' => ['index','about'],'except'=>true]

        ];
    }
     public function beforeAction($action)
     {
         $this->registerHomeCrumb();
         $this->registerIndexCrumb('??????');
         if ($action->id == 'error') {
             $this->registerCurrentCrumb('???????? ??????');
             $this->metaManager()->canonical();
         }
         return parent::beforeAction($action);
     }

    public function actionIndex()
    {
        $this->metaManager()->canonical(Url::to(['example/default']));
        $this->metaManager()->tag('description', 'Bla-bla-la-la-la');
        $this->metaManager()->prop('og:description', 'Bla-bla-bla');
        $this->metaManager()->prop('og:title', 'Bla-bla-bla');
        $this->metaManager()->keywords('Some, keywords,list');
        //Also
        return $this->render('index');
    }
     public function actionView(int $id)
     {
          $this->crumbCollection->addCrumb(
                new CrumbItem('Special crumb', Url::to(['some/page']), 20, ['target' => '_blank'])
           );
          $model = $this->pageFinder->findById($id);
          $this->registerCurrentCrumb($model->title);
          $this->metaManager()->ogMeta($model->title,Url::current([],true),$model->description,$model->cover,'article');
          return $this->render('about',['model'=>$model]);
     }

     ....

  Files folder image Files (27)  
File Role Description
Files folder imagesrc (1 file, 3 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:13
This week:0
All time:11,461
This week:524Up