PHP Classes

How Can PHP Set Meta Tags for Pages Using the Extension Yii2 Tagged View: Set page meta and other tags in view scripts

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-26 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 19 This week: 13All time: 11,230 This week: 7Up
Version License PHP version Categories
yii2-taggedview 1.0BSD License5HTML, PHP 5, Libraries, Design Patterns, S...
Description 

Author

This package can set page meta and other tags in view scripts.

It provides an extension to the Yii2 framework that allows developers to set some Web page properties as class variables in view scripts.

Currently, it supports page properties like:

- Article meta tag

- Page meta tags author, description, robots, keywords, generator

- Page rel canonical tag

- OpenGraph tags title, url, site_name, type, description, locale, updated_time and image

- Twitter meta tags card, title, URL, creator, site, type, description, label1, data1, label2, and data2

Innovation Award
PHP Programming Innovation award nominee
April 2024
Nominee
Vote
Meta tags are useful to define certain page properties that are not visible to users but can be useful for other applications and search engines like Google or social networks like Twitter and Facebook.

Many modern PHP applications use Model-View-Controller (MVC) frameworks that allow developers to define aspects of the presentation of the application pages with view scripts.

This package allows developers to easily set page property meta-tags using view scripts for applications developed using the Yii2 framework.

Manuel Lemos
Picture of Gabriel Alejandro López López
  Performance   Level  
Name: Gabriel Alejandro López ... <contact>
Classes: 7 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 3x

Documentation

TaggedView

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Extension to help setup the standard HTML meta tags besides the ones defined by Opengraph and TwitterCard to contribute to website SEO

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist daxslab/yii2-taggedview "*"

or add

"daxslab/yii2-taggedview": "*"

to the require section of your composer.json file.

Configuration

Configure the View component into the main configuration file of your application:

'components' => [
    //...
    'view' => [
        'class' => 'daxslab\taggedview\View',
        //configure some default values that will be shared by all the pages of the website
        //if they are not overwritten by the page itself
        'image' => 'http://domain.com/images/default-image.jpg',
    ],
    //...
]


Defaults

The component will try to set some properties by default:

$this->site_name = Yii::$app->name;
$this->url = Yii::$app->request->baseUrl;
$this->locale = Yii::$app->language;

You can overwrite the content of this tags in every page or in the component configuration.

Usage

Once the extension is configured, simply use it in your views by:

<?php 
    $this->title = 'page title';
    $this->description = 'page description';
    $this->keywords = ['keywords', 'for', 'this', 'page'];
    $this->image = 'http://domain.com/images/page-image.jpg'; 
?>

Proudly made by Daxslab.


  Files folder image Files  
File Role Description
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file View.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:19
This week:13
All time:11,230
This week:7Up