Download the PHP package romi45/yii2-seo-behavior without Composer
On this page you can find all versions of the php package romi45/yii2-seo-behavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-seo-behavior
Seo meta contents behavior for Yii 2
This extension provides behavior functions for seo meta tags and title tag support. Also provides view helper for registering meta tags and title.
Installation
My favorite way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json
file.
and then run migration
Configuring
First you need to configure your model:
Now you are ready to use it on form
As you can see, seoTitle
, seoKeywords
and seoDescription
is the attributes (by default) from which we can access SEO content of model.
Once you post a form with the above fields, they will be automatically saved and linked to our Post
model.
To register meta tags and set title in view use following code:
Do not forget about title tag in layout.
Patterns
You can use patterns in values and it will replaced with some model properties, application config property, application parameter or view parameter type will defined by prefixes.
Model Attribute
For example will replace with
Application Global Config Attribute
For example will replace with
Application Global Parameter Attribute
For example will replace with
View Global Parameter Attribute
For example will replace with .
Separator
By default separator pattern replaced with '-'. If you want to use another value for separator you need to identify param.
Hint: instead of 'titleSeparator' you can use constant value.
Global Seo Pattern
You can use global seo pattern to all model istance by set is_global
parameter to to 1
for model seoContent
.
Just create form in view like this:
And process it at you controller like this:
Sql Caching
For enable sql queries caching set enableSqlQueryCache
parameter
at behavior config to to true
. Also you can set
cache duration by sqlQueryCacheDuration
parameter. Example:
License
The MIT License (MIT). Please see License File for more information.