2017 © Pedro Peláez
 

yii2-extension yii2-metacrumbs

alternative way for work with breadcrumbs and meta

image

insolita/yii2-metacrumbs

alternative way for work with breadcrumbs and meta

  • Friday, November 3, 2017
  • by Insolita
  • Repository
  • 2 Watchers
  • 2 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2 meta-crumbs pack

alternative way for work with breadcrumbs and metadata with open-graph-protocol helpers, (*1)

also include NoLayoutBehavior for registration actions where layout must be skipped, (*2)

Status Latest Stable Version Total Downloads License, (*3)

Installation

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

Either run, (*5)

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

or add, (*6)

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

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

Usage

  • register MetaCrumbsBootstrap, or manual register as singleton :
 \Yii::$container->setSingleton(IBreadcrumbCollection::class,BreadCrumbs::class);
 ```
and/or

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

```, (*9)

  • add widget in layout, (*10)

       <?= \insolita\metacrumbs\widgets\CrumbWidget::widget([]) ?>
    
  • add CrumbedControllerTrait in base controller (or in needed controllers) and register crumbs, (*11)

  • add MetaManagerTrait in needed controllers or base controller (also in service possible), (*12)

    Controller Example, (*13)

    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]);
     }
    
     ....
    

The Versions

03/11 2017

dev-master

9999999-dev

alternative way for work with breadcrumbs and meta

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Insolita

extension yii2

29/05 2017

1.0

1.0.0.0

alternative way for work with breadcrumbs and meta

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Insolita

extension yii2