|  | 
 
|   
首先,咱们来分析一下首页index.php
x
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册  
 复制代码<?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[newsurl]."">".$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。感谢分享!
 | 
 |