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   View files Documentation   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 13 All time: 11,309 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  
Name: Insolita <contact>
Classes: 23 packages by
Country: Russian Federation Russian Federation
Age: 38
All time rank: 332991 in Russian Federation Russian Federation
Week rank: 97 Up8 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 16x

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  
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

  Files folder image Files  /  src  
File Role Description
Files folder imagecomponents (5 files)
Files folder imagemixins (3 files)
Files folder imagewidgets (1 file)
  Plain text file MetaCrumbsBootstrap.php Class Class source

  Files folder image Files  /  src  /  components  
File Role Description
  Plain text file BreadCrumbs.php Class Class source
  Plain text file CrumbItem.php Class Class source
  Plain text file IBreadcrumbCollection.php Class Class source
  Plain text file IMetaManager.php Class Class source
  Plain text file MetaManager.php Class Class source

  Files folder image Files  /  src  /  mixins  
File Role Description
  Plain text file CrumbedControllerTrait.php Class Class source
  Plain text file MetaManagerTrait.php Class Class source
  Plain text file NoLayoutBehavior.php Class Class source

  Files folder image Files  /  src  /  widgets  
File Role Description
  Plain text file CrumbWidget.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageconfig (2 files)
Files folder imageunit (4 files, 1 directory)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file bootstrap.php Example Example script
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file yii Example Example script

  Files folder image Files  /  tests  /  config  
File Role Description
  Accessible without login Plain text file base.php Aux. Auxiliary script
  Accessible without login Plain text file console.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
Files folder imagewidgets (1 file)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file BreadCrumbsTest.php Class Class source
  Plain text file MetaManagerTest.php Class Class source
  Plain text file NoLayoutBehaviorTest.php Class Class source

  Files folder image Files  /  tests  /  unit  /  widgets  
File Role Description
  Plain text file CrumbWidgetTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:13
This week:0
All time:11,309
This week:524Up