northug / yii2-meta-tags
Мета теги и тайтлы для моделей
1.0.0
2019-02-08 08:57 UTC
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2025-03-14 23:08:54 UTC
README
Add Meta Tags and Title in model
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist northug/yii2-meta-tags "*"
or add
"northug/yii2-meta-tags": "*"
to the require section of your composer.json
file.
Migrate:
yii migrate --migrationPath=@northug/metaTags/migrations
Usage
Once the extension is installed, simply use it in your code by :
Add MetaTagBehavior
to your model, and configure it.
public function behaviors()
{
return [
'MetaTag' => [
'class' => MetaTagBehavior::className(),
],
];
}
In form
<?= $form->field($model, 'meta')->widget(MetaTagsWidget::class)->label('SEO') ?>
and registar tags
$model = Model::findOne(1);
$model->getBehavior('MetaTag')->register();