chemezov/yii-seo

为 Yii PHP 框架提供的搜索引擎优化。

安装数: 3,348

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 10

开放问题: 0

类型:yii-extension

v1.0.4 2015-08-19 04:10 UTC

This package is auto-updated.

Last update: 2024-09-11 19:15:13 UTC


README

为 Yii PHP 框架提供的搜索引擎优化。

基于 crisu83 的 yii-seo

使用方法

在布局中

    <?php Yii::app()->controller->widget(
        'vendor.chemezov.yii-seo.widgets.SeoHead',
        array(
            'httpEquivs'         => array(
                'Content-Type'     => 'text/html; charset=utf-8',
                'X-UA-Compatible'  => 'IE=edge,chrome=1',
                'Content-Language' => 'en-EN'
            ),
            'defaultTitle'       => "My default title",
            'defaultDescription' => "My default description",
            'defaultKeywords'    => "My default keywords",
        )
    ); ?>

在控制器中

    public function behaviors()
    {
        return array(
            'seo' => array('class' => 'vendor.chemezov.yii-seo.behaviors.SeoBehavior'),
        );
    }

    public function filters()
    {
        return array(
            array('vendor.chemezov.yii-seo.filters.SeoFilter + view'), // apply the filter to the view-action
        );
    }

在视图文件中


$this->title = [$model->title, "My cool site!"];
$this->metaDescription = "My page description";
$this->metaKeywords = "My page keywords";