更改V9 SEO函数 $SEO['title'] $SEO['keyword'] $SEO['description']

栏目:PHPCMS 来源:网络 关注:0 时间:2019-09-23

更改V9 SEO函数 $SEO['title'] $SEO['keyword'] $SEO['description']

PHPCMS V9默认的是当你某栏目填写了SEO信息之后,会继承到下级未添加SEO信息的栏目和内容。如果不想这样,可以用下面方法解决。

解决办法:

打开“根目录/phpcms/libs/functions/global.func.php”,找到
function seo(约1435行),将原来的SEO函数替换为
function seo($siteid, $catid = '', $title = '', $description = '', $keyword = '') {
if (!empty($title))$title = strip_tags($title);
if (!empty($description)) $description = strip_tags($description);
if (!empty($keyword)) $keyword = str_replace(' ', ',', strip_tags($keyword));
$sites = getcache('sitelist', 'commons');
$site = $sites[$siteid];
$cat = array();
if (!empty($catid)) {
$siteids = getcache('category_content','commons');
$siteid = $siteids[$catid];
$categorys = getcache('category_content_'.$siteid,'commons');
$cat = $categorys[$catid];
$cat['setting'] = string2array($cat['setting']);
}
$seo['site_title'] =isset($site['site_title']) && !empty($site['site_title']) ? $site['site_title'] : $site['name'];
$seo['keyword'] = !empty($keyword) ? $keyword : '';
$seo['description'] = isset($description) && !empty($description) ? $description : (isset($cat['setting']['meta_description']) && !empty($cat['setting']['meta_description']) ? $cat['setting']['meta_description'] : (isset($site['description']) && !empty($site['description']) ? '' : ''));
$seo['title'] = (isset($title) && !empty($title) ? $title.' - ' : '').(isset($cat['setting']['meta_title']) && !empty($cat['setting']['meta_title']) ? $cat['setting']['meta_title'].' - ' : (isset($cat['catname']) && !empty($cat['catname']) ? $cat['catname'].' - ' : ''));
foreach ($seo as $k=>$v) {
$seo[$k] = str_replace(array("/-/n","/-/r"), '', $v);
}
return $seo;

本文标题:更改V9 SEO函数 $SEO['title'] $SEO['keyword'] $SEO['description']
本文地址:http://www.q0738.com/phpcms/18424.html

上一篇:phpcms V9模板标签说明 下一篇:没有了