承接 laco-agency/seo-behavior 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

laco-agency/seo-behavior

Composer 安装命令:

composer require laco-agency/seo-behavior

包简介

Seo behavior for Yii2 models and meta tags helper

README 文档

README

Seo behavior for Yii2 models and meta tags helper

Installing

composer require --prefer-dist laco-agency/seo-behavior

or add

"laco-agency/seo-behavior": "*"

to the require section of your composer.json.

Usage

Model:

use laco/seo/SeoModelBehavior;
public function behaviors()
{
    return [
        [
            'class' => SeoModelBehavior::className(),
            'descriptionFromAttribute' => 'teaser',
            'metaImageAttribute' => 'image_preview'
       ]
   ]
}

Controller:

use laco/seo/SeoControllerBehavior;

Attach behavior:

public function behaviors()
{
    return [
        SeoControllerBehavior::className()
   ];
}

In case when parent controller already has behaviors, you can attach SeoControllerBehavior like this:

public function behaviors()
{
    $behaviors = [
        'access' => [
            'class' => AccessControl::className(),
            'rules' => []
        ],
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => []
        ]
    ];
    return array_merge(parent::behaviors(), $behaviors);
}

Or like this:

public function init()
{
    $this->attachBehavior('seo', SeoControllerBehavior::className());
}

Action:

In the action use the method $this->setMetaTags($model) and pass $model as parameter;

public function view($slug)
{
    $model = Material::findOne(['slug' => $slug]));
    $this->setMetaTags($model);
}

Or use an array in this format instead of model:

[
    'metaTitle' => 'Custom meta title',
    'metaDescription' => 'Custom description',
    'metaImage' => 'Custom meta image'
]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固