Download the PHP package kovenant/yii2-seo-components without Composer
On this page you can find all versions of the php package kovenant/yii2-seo-components. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-seo-components
yii2-seo-components
Installation
The preferred way to install this extension is via composer.
Either run
or add this code line to the require
section of your composer.json
file:
SeoModelBehavior Usage
Add SeoModelBehavior to your model
{id}, {category_id} and {alias} will be replaced by the value of the attributes of the current model, that have such names
{category.alias} will be replaced by the value of the relation’s attribute
``
Behavior provides three methods:
-
$model->getRouteUrl()
will return route as array. Now you can use it for yii\widgets\Menu items 'url'Array ( [0] => catalog/item [categoryId] => 1 [categoryAlias] => category-alias [id] => 5 [alias] => item-alias )
-
$model->getUrl()
will return for example/catalog/1-category-alias/5-item-alias.html
$model->getAbsoluteUrl()
returnshttps://example.com/catalog/1-category-alias/5-item-alias.html
Don't forget to check your config file for pretty url settings
E.g.
``
MetaTagsWidget.php Usage
Add MetaTagsWidget to your view
``
In addition to the widget settings you can configure common widget options via container definitions in your config file
Example of full options:
``
componentNameAttribute
is required. Other component attributes are optional.
The text for default value of title and description is componentNameAttribute
.
If viewH1Attribute
and componentH1Attribute
are set they will be used as a default value.
componentTitleAttribute
, componentKeywordsAttribute
and componentDescriptionAttribute
will set corresponding meta tags.
i.e. default value = componentNameAttribute
<< componentH1Attribute
<< componentTitleAttribute
If you set absoluteUrlMethod
from SeoModelBehavior and current page of widget != absolute url from model, canonical link tag will be added.
You can inherit from MetaTagsWidget and add your own getters to use in templates, like {appName} and {pager}
See more examples of usage in tests.