denisok94/yii-metatag 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

denisok94/yii-metatag

Composer 安装命令:

composer require denisok94/yii-metatag

包简介

Generation of Yii2 meta tags.

README 文档

README

Generation of meta tags.

Installation

Run:

composer require --prefer-dist denisok94/yii-metatag
# or
php composer.phar require --prefer-dist denisok94/yii-metatag

or add to the require section of your composer.json file:

"denisok94/yii-metatag": "*"
composer update
# or
php composer.phar update

In the settings (config), where the web.php files are located or config.php specify the name of the site and the main language

$config = [
    'name' => 'Site Name',
    'language' => 'en-EN',
    'basePath' => dirname(__DIR__),
    //...
];

Use

Method Description
static::tag() Install MetaTag on the page
namespace app\controllers;
use \denisok94\helper\yii2\MetaTag;

class NewsController extends Controller
{
    // ...
    public function actionView($id)
    {
        $model = $this->findModel($id);
        //
        MetaTag::tag($this->view, [
            'title' => $model->title,
            'description' => substr($model->text, 0, 100),
            'keywords' => $model->tags, // string
        ]);
        // or
        $this->view->title = $model->title;
        list($width, $height, $type, $attr) = getimagesize(Yii::$app->getBasePath() . $model->image_path);
        MetaTag::tag($this->view, [
            'title' => $model->title,
            'description' => $model->announce,
            'keywords' => implode(', ', $model->tags), // if tags array
            'image' => Url::to($model->image_path, true),
            'image:src' => Url::to($model->image_path, true),
            'image:type' => 'image/jpeg',
            'image:width' => $width,
            'image:height' => $height,
        ]);
        //
        return $this->render('view', ['model' => $model]);
    }
}

Specified in action, before `render()'.

MetaTag::tag($this->view, [
    'nameTag1' => 'valueTag1',
    'nameTag2' => 'valueTag2',
    //...
]);

Individual icon(favicon) for the page

// Before
$this->view->registerLinkTag(['rel' => 'icon', 'type' => 'image/png', 'href' => Url::to("/favicon.png", true)]);
// Since MetaTag
// todo

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固