定制 sbs/yii2-seo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sbs/yii2-seo

Composer 安装命令:

composer require sbs/yii2-seo

包简介

The module allows link SEO fields to model.

README 文档

README

The module provides an ability to add SEO fields to Model. Fields: title, keywords, description.

Installation

The preferred way to install this extension is through composer.

Either run

composer require sbs/yii2-seo

or add to the require section of your application's composer.json file next line

"sbs/yii2-seo": "^1.0"

and run

composer update

Migrations

For add table, to DataBase, you can run next command

php yii migrate/up --migrationPath=vendor/sbs/yii2-seo/src/migrations

or you can configure your application's config\console.php

This method more preferable because you can run all standard migrations commands.

'controllerMap' => [
    'migrate' => [
        'class' => MigrateController::class,
        'migrationPath' => [
            '@console/migrations',
            '@vendor/sbs/yii2-seo/src/migrations',
        ],
        //...
    ],
    //...
]

Use with Model

You need to add behaviors to model:

use sbs\behaviors\SeoBehavior;

function behaviors()
{
    return [
    //...
        SeoBehavior::class,
    //...
    ];
}

Now all fields will be available by $model->seo.

For add/edit fields in model form view use next widget:

//...
use sbs\widgets\SeoForm;
//...
?>
<div>
    <?php $form = ActiveForm::begin(); ?>
    //...
    <?= SeoForm::widget(['model' => $model, 'form' => $form]); ?>
    //...
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create': 'Update'); ?>
    </div>
    <?php ActiveForm::end(); ?>
</div>

For display this field on page view use next widget:

use sbs\widgets\SeoTags;
//...
SeoTags::widget(['seo' => $model->seo]);
// ...

Use without Model

Also, you can use the SeoTags widget without model and DataBase. For example, if you need to add SEO to some static page and no need for editing this information in the admin panel:

use sbs\widgets\SeoTags;
//...
SeoTags::widget(['title' => 'title', 'keywords' => 'keyword 1, keyword 2', 'description' => 'your description']);
// ...

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-10-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固