2017 © Pedro Peláez
 

yii2-extension yii2-seo

Yii2 extension for simple generating keywords and description

image

shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  • Monday, October 19, 2015
  • by shershennm
  • Repository
  • 1 Watchers
  • 3 Stars
  • 798 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 45 % Grown

The README.md

yii2-seo

Yii2 module for easy creating meta tags, (*1)

Installation

composer require shershennm/yii2-seo:"^3.0", (*2)

Usage

In config file:, (*3)

<?php
...
'bootstrap' => ['log', 'seo'], // add seo component to application bootstrap
...
'components' => [
    ...
    'seo'         => [
        'class' => 'shershennm\seo\Seo',
        'controllerMapping' => [
            'app\controllers' => 'app\seo\controllers', // controller namespace for seo module
        ],

    ],
]

Seo controller example:, (*4)

<?php

namespace app\seo\controllers;

use Yii;
use shershennm\seo\SeoController;

class SiteController extends SeoController
{
    /**
    * $viewParams array View Params from actionIndex in SiteController
    **/
    public function actionIndex($viewParams)
    {
        $this->title = 'Hello world!';

        $this->registerMetaTag(['name' => 'description', 'content' => 'Cool page!']);
        $this->registerLinkTag([['rel' => 'next', 'href' => 'https://my-cool-page.lh/article/2']]);

        return [
            ['name' => 'keywords', 'content' => $this->getKeywords()], // params for View::registerMetaTag() function
            ['name' => 'description', 'content' => 'Cool page!'],
        ];
    }

    private function getKeywords()
    {
        // $this->controller instance of current controller
        return implode($this->controller->words, ', ');
    }

    ....

You can use OnePagSeoController for controller which have index action for different routes. Example:, (*5)

<?php

namespace frontend\seo\controllers;

use shershennm\seo\OnePageSeoController;

class SiteController extends OnePageSeoController
{
    protected $titles = [
        'site/info' => 'Site Info',
    ];
    protected $wildcardTitles = [
        '/site\/history/' => 'Site History',
    ];
}

Route of $titles will be applied only to pages with same route. $wildcardTitles use regular expression as route., (*6)

The Versions

19/10 2015

dev-master

9999999-dev https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 link seo meta keywords

19/10 2015

1.0.3

1.0.3.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 seo meta keywords

19/10 2015

2.0.0

2.0.0.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 seo meta keywords

19/10 2015

2.0.2

2.0.2.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 seo meta keywords

19/10 2015

2.0.3

2.0.3.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 link seo meta keywords

19/10 2015

3.0.0

3.0.0.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 link seo meta keywords

19/10 2015

dev-staging

dev-staging https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 link seo meta keywords

19/10 2015

3.1.0

3.1.0.0 https://github.com/shershennm/yii2-seo

Yii2 extension for simple generating keywords and description

  Sources   Download

MIT

The Requires

 

by Avatar shershennm

yii2 link seo meta keywords