crisu83/yii-seo

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

安装次数: 9,207

依赖者: 0

推荐者: 1

安全: 0

星标: 6

关注者: 4

分支: 10

类型:yii-extension

dev-master 2015-03-20 14:13 UTC

This package is auto-updated.

Last update: 2024-08-29 03:53:22 UTC


README

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

使用方法

在布局中

    <?php Yii::app()->controller->widget(
        'vendor.crisu83.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.crisu83.yii-seo.behaviors.SeoBehavior'),
        );
    }

    public function filters()
    {
        return array(
            array('vendor.crisu83.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";