PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > CMS教程 > phpcms教程 > 正文

    修改phpcms v9SEO函数 $SEO['title'] $SEO['keyword'] $SEO['description']

    作者:admin来源:网络浏览:时间:2020-09-30 00:07:50我要评论
    导读:V9默认的,当你某栏目填写了SEO信息之后,会继承到下级未添加SEO信息的栏目和内容。非常的烦人。修改步骤:打开:根目录/phpcms/libs/funct...
    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;
    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-101-1878-1.html
    相关热词搜索: