本站资源均来自互联网,仅供学习与参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
Copyright @ 2015-2020 织梦园 版权所有
Power by DedeCms
鲁ICP备15039853号-1
模板标签 TAG标签 网站地图 XML地图 今日更新 返回顶部
<title>{dede:field.seotitle/}</title> <meta name="keywords" content="{dede:field name='keywords'/}" /> <meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" /> |
DEDECMS 自动获取上级栏目的标题,关键字 描述
***步:打开/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']); } } |
//为了让某些栏目的关键字描述等不能为空 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]; } |
保存之后,这里我们去生成一下预览效果。