porcelanosa/yii2-seo-attributes

Yii2 Extenstion for set seo attributes

dev-master 2016-07-24 11:19 UTC

This package is not auto-updated.

Last update: 2024-04-11 00:22:50 UTC


README

WARNING! This package is UNDER DEVELOPMENT

Latest Stable Version Latest Unstable Version Total Downloads License composer.lock

yii2-seo-attributes

Yii2 extensions for adding seo attributes, like a title, meta-keys, meta-descr and other, in entity ##Installition

composer require porcelanosa/yii2-seo-attributes

Run migration

$ php yii migrate/up --migrationPath=@vendor/porcelanosa/yii2-seo-attributes/migrations

In model class add behavior

'seoBehavior' => [
    'class' => SeoBehavior::className(),
    'model_name' => $this::className(),
    'uploadPath' =>'@web/uploads/seoimage/'
],

In config add module

'modules' => [
    ...
    'seo' => [
        'class' => 'porcelanosa\yii2seo\Module',
        'uploadPath' =>'@web/uploads/seoimage/'
    ],
    ...
]

In admin view

echo \porcelanosa\yii2seo\SeoWidget::widget(
    [
        'model'        => $model,
        'form'         => $form,
        'behaviorName' => 'seoBehavior',
        'templateType' => 'minimum-minimorum' // 'minimal', 'standart', 'full'
    ] );

##Usage

$this->title = $model->seo->title;

or meta-tag

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

or in controller action

if ($model->seo) {
    // page title
    $this->getView()->title = $model->seo->title;
    // meta keywords
    $this->getView()->registerMetaTag([
        'name'    => 'description',
        'content' => $model->seo->meta_descr,
    ])
    ;
}

Screen shot

##Social meta tags Examples of using

https://moz.com/blog/meta-data-templates-123

or

http://www.iacquire.com/blog/18-meta-tags-every-webpage-should-have-in-2013

Twitter Card docs

https://dev.twitter.com/cards/overview

Open Graph docs

https://developers.facebook.com/docs/opengraph/getting-started

Google Schema.org docs

https://developers.google.com/+/web/snippet/

Schema.org types

http://schema.org/docs/schemas.html

Template Types

Extension provide tmplate type: 'only2', 'minimum', 'standart', 'full'

Full decription of template types