在dedecms當(dāng)中,所有的后臺欄目,都是指定所建的htm代碼,進(jìn)而網(wǎng)站會輸出內(nèi)容。最模板這次二次開發(fā)網(wǎng)站,有幸找了寫該函數(shù)。
如下:
function GetTempletFile()
{
global $cfg_basedir,$cfg_templets_dir,$cfg_df_style;
$cid = $this->ChannelUnit->ChannelInfos['nid'];
if(!empty($this->Fields['templet']))
{
$filetag = MfTemplet($this->Fields['templet']);
// if( !preg_match("#\/#", $filetag) ) $filetag = $GLOBALS['cfg_df_style'].'/'.$filetag;
}
else
{
$filetag = MfTemplet($this->TypeLink->TypeInfos["temparticle"]);
}
$tid = $this->Fields['typeid'];
$filetag = str_replace('{cid}', $cid,$filetag);
$filetag = str_replace('{tid}', $tid,$filetag);
$tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag;
if($cid=='spec')
{
if( !empty($this->Fields['templet']) )
{
$tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag;
}
else
{
$tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/article_spec.htm";
}
}
if(!file_exists($tmpfile))
{
$tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/".($cid=='spec' ? 'article_spec.htm' : 'article_default.htm');
}
if (!preg_match("#.htm$#", $tmpfile)) return FALSE;
return $tmpfile;
}
關(guān)鍵部分是 $tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag;
意思 文章頁調(diào)用不同模型下的指定模板。 $filetag = MfTemplet($this->TypeLink->TypeInfos["temparticle"]); 以這個(gè)循環(huán)指定。
那么如果做單獨(dú)頁,需要指定某個(gè)模板,直接修改$tmpfile 就可以了。