admin 发表于 2014-4-8 09:12:21

教你用不同的首页模板制作帝国CMS多个动态首页

首先,咱们来分析一下首页index.php
<?php
require('e/class/connect.php');
require('e/class/db_sql.php');
require('e/class/functions.php');
require('e/class/t_functions.php');
require('e/data/dbcache/class.php');
require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
$link=db_connect();
$empire=new mysqlquery();
$pr=$empire->fetch1("select sitekey,siteintro from {$dbtbpre}enewspublic limit 1");
//页面
$pagetitle=htmlspecialchars($public_r['sitename']);
$pagekey=htmlspecialchars($pr['sitekey']);
$pagedes=htmlspecialchars($pr['siteintro']);
$url="<a href=\"".$public_r."\">".$fun_r['index']."</a>";//栏目导航
$indextemp=GetIndextemp();//取得模板
$string=DtNewsBq('indexpage',$indextemp,0);
$string=str_replace('[!---newsnav--]',$url,$string);//位置导航
$string=ReplaceSvars($string,$url,0,$pagetitle,$pagekey,$pagedes,$addr,0);
$string=str_replace('[!---page.stats--]','',$string);
echo stripSlashes($string);
db_close();
$empire=null;
?>
主要的就是:
$indextemp=GetIndextemp();//取得模板
$string=DtNewsBq('indexpage',$indextemp,0);

这2句是查询和处理模板的,现在我们默认的已经启用了首页模板,现在想把首页方案1模板也给他给index1.php 让他显示出来方案1的模板首页,那么,就根据我下面的步骤改吧!




分析过后咱发现 GetIndextemp()是在e/class/functions.php 里面,我们搜索 GetIndextemp 在这下面增加
//取得首页模板2
function GetIndextemp1($mbid){
global $empire,$dbtbpre,$public_r;
$r=$empire->fetch1("select temptext from {$dbtbpre}enewsindexpage where tempid='".$mbid."'");
return $r['temptext'];
}
然后搜索 DtNewsBq 在下面增加:
//标签替换5
function DtNewsBq1($classid,$indextext,$ecms=0){
global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
$cachetime=$ecms==1?$public_r['dtncachetime']:$public_r['dtcachetime'];
$file=ECMS_PATH.'e/data/tmp/indexpage'.$classid.'.php';
if($cachetime&&file_exists($file)){
$filetime=filemtime($file);
if(time()-$cachetime*60<=$filetime){
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
return $string;
}}
$indextext=stripSlashes($indextext);
$indextext=ReplaceTempvar($indextext);//替换全局模板变量
//替换标签
$indextext=DoRepEcmsLoopBq($indextext);
$indextext=RepBq($indextext);
//写文件
WriteFiletext($file,AddCheckViewTempCode().$indextext);
//读取文件内容
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
return $string;
}

最后自己把index.php复制一份改名为index1.php 那么,如果你想这个页面显示首页模板方案1的首页,那么就这样修改吧

$indextemp=GetIndextemp1(1);//取得模板
$string=DtNewsBq1('1',$indextemp,0);
然后打开你的网址/index1.php 试试吧! 第2个首页可以打开了哦!


PS:本教程来自帝国CMS爱好者yecha官方网站www.52img.cn。感谢分享!
页: [1]
查看完整版本: 教你用不同的首页模板制作帝国CMS多个动态首页