婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 網(wǎng)站建設(shè) > 建站知識 > dede自動動獲取上級欄目的標(biāo)題 關(guān)鍵字 描述

dede自動動獲取上級欄目的標(biāo)題 關(guān)鍵字 描述

POST TIME:2020-04-10 18:40

當(dāng)我們做大型網(wǎng)站的時(shí)候,上百個(gè)欄目,為了SEO,在欄目模板里面,我們一般會像下面這樣去調(diào)用欄目標(biāo)題、關(guān)鍵字、描述。
<title>{dede:field.seotitle/}</title> <meta name="keywords" content="{dede:field name='keywords'/}" /> <meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" /> 但是這樣有一個(gè)問題,就是假如個(gè)別欄目忘記寫標(biāo)題、關(guān)鍵字、描述就會為空了。這時(shí)我們可能就會想,如果能讓欄目標(biāo)題、關(guān)鍵字、描述為空的時(shí)候,就調(diào)用上級的就好了,當(dāng)上級沒有時(shí)候時(shí)候,再調(diào)用上上級的,如果到頂級欄目都還沒有的時(shí)候,就調(diào)用用網(wǎng)站首頁的標(biāo)題、關(guān)鍵字、描述,想法是可以,但是實(shí)現(xiàn)起來可能不容易。今天我就來分享一下我的方法吧。
DEDECMS 自動獲取上級欄目的標(biāo)題,關(guān)鍵字 描述
第一步:打開/include/typelink.class.php 找到這一段代碼$this->TypeInfos = $this->dsql->GetOne($query); 在他下面加上三行代碼加好之后如下
//載入類目信息 $query = "SELECT tp.*,ch.typename as ctypename,ch.addtable,ch.issystem FROM `idea_arctype` tp left join `idea_channeltype` ch on ch.id=tp.channeltype WHERE tp.id='$typeid' "; if($typeid > 0) { $this->TypeInfos = $this->dsql->GetOne($query); //填空 $this->TypeInfos['keywords'] = $this->TypeInfos['keywords'] ? $this->TypeInfos['keywords'] : $this->GetTrueInfos('keywords'); $this->TypeInfos['seotitle'] = $this->TypeInfos['seotitle'] ? $this->TypeInfos['seotitle'] : $this->GetTrueInfos('seotitle'); $this->TypeInfos['description'] = $this->TypeInfos['description'] ? $this->TypeInfos['description'] : $this->GetTrueInfos('description'); if(is_array($this->TypeInfos)) { $this->TypeInfos['tempindex'] = MfTemplet($this->TypeInfos['tempindex']); $this->TypeInfos['templist'] = MfTemplet($this->TypeInfos['templist']); $this->TypeInfos['temparticle'] = MfTemplet($this->TypeInfos['temparticle']); } }
第二步:在TypeLink類中增加一個(gè)調(diào)用方法GetTrueInfos($info) 代碼如下:
//為了讓某些欄目的關(guān)鍵字描述等不能為空 function GetTrueInfos($info = 'seotitle') { $infos = array('reid'=>$this->TypeID,$info=>''); while(empty($infos[$info]) && $infos['reid']!=0) { $this->dsql->SetQuery("SELECT reid,".$info." FROM idea_arctype WHERE id='".$infos['reid']."'"); $infos = $this->dsql->GetOne(); } if(empty($infos[$info])) { if($info == "seotitle") return $GLOBALS['cfg_webname']; if($info == "keywords") return $GLOBALS['cfg_keywords']; if($info == "description") return $GLOBALS['cfg_description']; } return $infos[$info]; }
保存之后,這里我們?nèi)ド梢幌骂A(yù)覽效果,此方法在DEDECMS 5.7 SP1上測試有效,其它版本未測試。 在此獻(xiàn)丑了


收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 九江市| 甘谷县| 尉氏县| 象州县| 凭祥市| 伽师县| 娄底市| 沙坪坝区| 石嘴山市| 南丹县| 惠州市| 海林市| 安阳市| 乌苏市| 马鞍山市| 玛沁县| 遂宁市| 大邑县| 邓州市| 铜川市| 昭苏县| 凉城县| 包头市| 定结县| 乐山市| 淮北市| 龙岩市| 安龙县| 蛟河市| 依安县| 东城区| 南宫市| 新干县| 伊金霍洛旗| 溧阳市| 齐齐哈尔市| 习水县| 融水| 曲麻莱县| 西乌| 新丰县|