Skip to content
forked from pistol88/yii2-seo

Модуль позволяет привязывать SEO поля к моделям

License

Notifications You must be signed in to change notification settings

liemuar/yii2-seo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2-seo

Модуль дает возможность быстро присвоить и быстро распаковать СЕО поля: титл, дескрипшн, кейвордс (ТДК) и т.д.

Установка

Выполнить команду

php composer require liemuar/yii2-seo "*"

Или добавить в composer.json

"liemuar/yii2-seo": "*",

И выполнить

php composer update

Миграция:

php yii migrate --migrationPath=vendor/liemuar/yii2-seo/migrations

Использование

К модели подключить поведение:

    function behaviors()
    {
        return [
            'seo' => [
                'class' => 'liemuar\seo\behaviors\SeoFields',
            ],
        ];
    }

Теперь все СЕО поля доступны при вызове $model->seo.

Пример использования во вью файле:

if(!$title = $model->seo->title) {
    $title = "Купить {$model->name} в Кургане в магазине «Шоп45»";
}

if(!$description = $model->seo->description) {
    $description = 'Страница '.$model->name;
}

if(!$keywords = $model->seo->keywords) {
    $keywords = '';
}

$this->title = $title;

$this->registerMetaTag([
    'name' => 'description',
    'content' => $description,
]);

$this->registerMetaTag([
    'name' => 'keywords',
    'content' => $keywords,
]);

Виджеты

Ввод СЕО полей:

<?=\liemuar\seo\widgets\SeoForm::widget([
        'model' => $model, 
        'form' => $form, 
    ]); ?>

Его необходимо вызвать внутри формы редактирования вашей модели.

About

Модуль позволяет привязывать SEO поля к моделям

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 92.4%
  • JavaScript 4.3%
  • CSS 3.3%