maks757/yii2-seo

此包的最新版本(v1.1.0)没有可用的许可证信息。

Yii框架的SEO扩展

维护者

详细信息

github.com/maks757/yii2-seo

源代码

安装: 45

依赖者: 2

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 1

类型:yii2-extension

v1.1.0 2018-05-15 15:53 UTC

This package is not auto-updated.

Last update: 2024-09-20 22:58:35 UTC


README

Yii框架SEO优化模块

yii migrate --migrationPath=@vendor/maks757/yii2-seo/migrations

ActiveRecord配置行为

public function behaviors()
{
    return [
        'seo_data' => [
            'class' => 'maks757\seo\behaviors\SeoDataBehavior',
            'generation_field' => 'title'
        ],
        //...
    ];
}

添加规则

public function rules()
{
    return [
        //...
        [['seoUrl', 'seoTitle',], 'string', 'max' => 255],
        [['seoKeywords',], 'string', 'max' => 512],
        [['seoDescription',], 'string', 'max' => 1024],
    ];
}

您可以添加属性

/**
 * @property string $seoUrl
 * @property string $seoTitle
 * @property string $seoKeywords
 * @property string $seoDescriptin
 */

并将输入添加到表单中

<?= $form->field($model, 'seoUrl')->textInput() ?>
<?= $form->field($model, 'seoTitle')->textInput() ?>
<?= $form->field($model, 'seoDescription')->textarea() ?>
<?= $form->field($model, 'seoKeywords')->textarea() ?>