2017 © Pedro Peláez
 

yii2-component yii2-metamaster

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

image

floor12/yii2-metamaster

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

  • Thursday, July 5, 2018
  • by floor12
  • Repository
  • 1 Watchers
  • 1 Stars
  • 16 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

yii2-metamaster

Build Status Scrutinizer Code Quality Latest Stable Version Latest Unstable Version Total Downloads License, (*1)

Этот файл так же доступен на русском языке., (*2)

This is a component for generate some Meta, Open Graph and Twitter-card tags in a template header of Yii2 app., (*3)

This is a list of supported tags: - canonical - head title - meta description - meta keywords - og:sitename - og:type - og:url - og:title - og:description - og:image - og:image:width - og:image:height - twitter:card - twitter:domain - twitter:site - twitter:description - twitter:image:src - itemprop:name - itemprop:image, (*4)

Installation

Just run:, (*5)

$ composer require floor12/yii2-metamaster

or add this to the require section of your composer.json., (*6)

"floor12/yii2-metamaster": "dev-master"

After that, include some basic metamaster data into components section of application config., (*7)

    'components' => [
        'metamaster' => [
            'class' => 'floor12\metamaster\MetaMaster',
            'siteName' => 'My cool new Web Site',
            'defaultImage' => '/design/export_logo.png',
        ],
    ...

Attributes: 1. siteName - name of project to show in Open Graph tags; 2. defaultImage - web relative path to default image for Open Graph tags; 3. web - yii2 alias to web path to read image width and height for Open Graph tags (default is @app/web) 4. protocol - default protocol to generate links (default is https), (*8)

Usage

Its possible to use in any place of your app. Just use setters and then call the register(View $view) method with View object passed into it., (*9)

Allowed setters:, (*10)

Metamaster::setSiteName(string $value)
Metamaster::setTitle(string $value)
Metamaster::setUrl(string $value)
Metamaster::setType(string $value)
Metamaster::setDescription(string $value)
Metamaster::setImage(string $relativePath, string $absolutePath = null)

For example, using in controller:, (*11)

public function actionIndex()
   {
        Yii::$app->metamaster
                   ->setTitle("This is test page")
                   ->setDescription("This is page description")
                   ->setImage('/images/article/image.png')
                   ->register(Yii::$app->getView());

        return $this->render('index');
    }

It will generate all you need in template:, (*12)

<title>This is test page</title>
<link href="https://your-domain.com/site/index" rel="canonical">
<meta name="description" content="This is page description">
<meta property="og:site_name" content="My cool new Web Site">
<meta property="og:type" content="article">
<meta property="og:url" content="https://your-domain.com/site/index">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="https://your-domain.com">
<meta name="twitter:site" content="My cool new Web Site">
<meta property="og:title" content="This is test page">
<meta itemprop="name" content="This is test page">
<meta property="og:description" content="This is page description">
<meta name="twitter:description" content="This is page description">
<meta property="og:image" content="https://your-domain.com/images/article/image.png">
<meta property="twitter:image:src" content="https://your-domain.com/images/article/image.png">
<meta itemprop="image" content="https://your-domain.com/images/article/image.png">

The Versions

05/07 2018

dev-master

9999999-dev

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar floor12

yii2 yii yii 2 seo meta opengraph floor12 yii2 component

05/07 2018

v1.0.0

1.0.0.0

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar floor12

yii2 yii yii 2 seo meta opengraph floor12 yii2 component

05/07 2018

v0.1.1

0.1.1.0

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar floor12

yii2 yii yii 2 seo meta opengraph floor12 yii2 component

05/07 2018

v0.1.0

0.1.0.0

This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.

  Sources   Download

MIT

by Avatar floor12

yii2 yii yii 2 seo meta opengraph floor12 yii2 component