完善前台seo功能
This commit is contained in:
@@ -17,6 +17,7 @@ use app\model\Config;
|
||||
use think\facade\Route;
|
||||
use think\facade\Event;
|
||||
use app\model\Hooks;
|
||||
use app\model\SeoRule;
|
||||
|
||||
class Base {
|
||||
|
||||
@@ -216,4 +217,27 @@ class Base {
|
||||
$doc = new \doc\Doc();
|
||||
return $doc->parse($text);
|
||||
}
|
||||
|
||||
protected function setSeo($title = '', $keywords = '', $description = '') {
|
||||
$seo = array(
|
||||
'title' => $title,
|
||||
'keywords' => $keywords,
|
||||
'description' => $description,
|
||||
);
|
||||
//获取还没有经过变量替换的META信息
|
||||
$meta = SeoRule::getMetaOfCurrentPage($this->request, $seo);
|
||||
foreach ($seo as $key => $item) {
|
||||
if (is_array($item)) {
|
||||
$item = implode(',', $item);
|
||||
}
|
||||
$meta[$key] = str_replace("[" . $key . "]", $item . '|', $meta[$key]);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'title' => $meta['title'],
|
||||
'keywords' => $meta['keywords'],
|
||||
'description' => $meta['description'],
|
||||
);
|
||||
View::assign('seo', $data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user