understeam/yii2-seo-toolbar

Installs: 174

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 7

Forks: 1

Open Issues: 0

Language:CSS

Type:package

v0.3 2015-12-04 09:47 UTC

This package is not auto-updated.

Last update: 2024-12-21 19:37:20 UTC


README

This toolbar allows to easily configure title of page, meta tags or Open Graph tags on your website. It doesn't require any administration panel, it works right in the place (as Yii2 Debug Toolbar).

Requirements

This extension requires Redis to be installed and configured as redis application component. The main model class relies on yii\redis\ActiveRecord

Installation

$ composer require understeam/yii2-seo-toolbar:0.3 --prefer-dist

Usage

At first, add toolbar to modules configuration and add it into application bootstrap:

...
'bootstrap' => ['seoToolbar'],
'modules' => [
    'seoToolbar' => [
        'class' => 'understeam\seotoolbar\Module',
        'permission' => 'seo', // permission to check
        'allowedIPs' => ['*'],
    ],
],
...

It is strongly recommended to use name seoToobar because it is hardcoded (yet).

Access control

At this step toolbar should appear if you are logged in and you have permission seo. Basically, module checks permissions with this method:

Yii::$app->user->can('seo');

So, if you are not using RBAC and access checks you can make toolbar visible for any logged in user:

...
'bootstrap' => ['seoToolbar'],
'modules' => [
    'seoToolbar' => [
        'class' => 'understeam\seotoolbar\Module',
        'permission' => '@', // allow to any logged in user
        'allowedIPs' => ['*'],
    ],
],
...

Also, you may want to show toolbar ALL users and check permissions via IP address:

...
'bootstrap' => ['seoToolbar'],
'modules' => [
    'seoToolbar' => [
        'class' => 'understeam\seotoolbar\Module',
        'permission' => null, // allow to any logged in user
        'allowedIPs' => ['127.0.0.1', '192.168.0.1'],
    ],
],
...

Url patterns and model attributes

There is possibility to use a star (*) symbol to transform URL to regular expression:

Screenshot

Using SeoEntity behavior

Use SeoEntity class as a behavior for your models which attributes you want to use as a parameters in seo toolbar:

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            'seo' => [
                'class' => 'understeam\seotoolbar\behaviors\SeoEntity',
                'attributes' => [
                    'name',
                    'slug',
                    'description'
                ],
            ],
        ]);
    }

Screenshot