yii2-meta Databased based automated page meta tags based on route and named parameters

Web Page Metadata

  1. What's next
  2. Installation
  3. Usage

DB based web page metadata for SEO performance annoying free development.

Latest updates<br/> https://github.com/ptheofan/yii2-meta

What's next

Take into account the route named parameters

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ptheofan/yii2-meta "*"

or add

"ptheofan/yii2-meta": "*"

to the require section of your composer.json file.

Usage

Basic Usage In your components configuration add the following

'meta' => [
    'class' => 'ptheofan\meta\Meta',
]

run the migration by running ~~~ ./yii migrate --migrationPath="@vendor/ptheofan/yii2-meta/migrations" ~~~

In your code, if you want to automatically set the metadata for a page call

Yii::$app->meta->setMeta();

This will automatically load the correct row from the database using the currently running route (module/controller/action or controller/action). It will automatically identify and set the canonical, the og:url. The reset depend on the database entry, the argument used and the defaults as identified in your component config.

You can optionally override data by specifying them in a parameter array

Yii::$app->meta->setMeta(['title' => 'My cool override']);

or you can use defaults to be used throughout the site in the component config

'meta' => [
    'class' => 'ptheofan\meta\Meta',
    'defaults' => [
        'og:type' => 'website',
        'author' => 'My Cool Company',
    ],
]

The defaults will always override any values passed in through parameter or through the database.

0 0
3 followers
0 downloads
Yii Version: 2.0
License: MIT
Category: Others
Tags:
Developed by: Elecen
Created on: Oct 24, 2014
Last updated: 5 years ago