Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 13 | All time: 11,461 This week: 524![]() |
Version | License | PHP version | Categories | |||
yii2-metacrumbs 1.0 | MIT/X Consortium ... | 5 | PHP 5, Graphics, Design Patterns |
Description | Author | |
This package can generate breadcrumbs for navigating between pages. |
|
alternative way for work with breadcrumbs and metadata with open-graph-protocol helpers
also include NoLayoutBehavior for registration actions where layout must be skipped
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.
- 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]);
}
....
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
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. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.