jpunanua / yii2-seotools
组件和模块,用于管理页面独特的SEO标题、描述、关键词和与页面关联的独特文本
dev-master
2015-04-09 14:16 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-28 16:39:50 UTC
README
如果您需要为页面设置独特的SEO标题和描述,这个扩展就是您所需要的,您还可以使用所见即所得工具添加HTML文本、加粗和链接,以改善页面独特内容的SEO。
使用模块设置这些字段,以管理所有这些功能。
使用md5哈希将(Host + Path)组合成一个唯一的ID,以标识页面、yii缓存系统和标签依赖关系,以提高速度
安装
安装此扩展的首选方式是通过composer。
运行以下命令
php composer.phar require --prefer-dist jpunanua/yii2-seotools "*"
或者在您的composer.json
文件的require部分添加
"jpunanua/yii2-seotools": "*"
###迁移
在终端运行以下命令进行数据库迁移
Linux/Unix
yii migrate/up --migrationPath=@vendor/jpunanua/yii2-seotools/migrations
Windows
yii.bat migrate/up --migrationPath=@vendor/jpunanua/yii2-seotools/migrations
###配置
开启seotool组件的简单示例。
'components' => [ 'seotools' => [ 'class' => 'jpunanua\seotools\Component', ], ],
开启seotools模块
简单示例
'modules' => [ 'seotools' => [ 'class' => 'jpunanua\seotools\Module', 'roles' => ['@'], // For setting access levels to the seotools interface. ] ],
用法
扩展安装后,只需在您的代码中简单使用即可
// @param bool $setCanonical true, try to create a canonical url and og url, action needs to have params // @param bool $checkDb try to get from DB params, true: try to get info from DB if it doesn't find save a new field // associated to current host + '/' + path, false: it just set the params give in the call. The db params has priority // over the call function params. It does a merge $setCanonical = false; $checkDb = true; Yii::$app->seotools->setMeta(['title' => \Yii::t('title','A good title for this page')], $setCanonical, $checkDb);
您可以通过调用无效化缓存来保存记录
\yii\caching\TagDependency::invalidate(Yii::$app->cache, jpunanua\seotools\Component::CACHE_TAG);
###URLs
seotools管理模块的URL
/seotools/manage /seotools/manage/create