PHPIN.NET

 找回密码
 立即注册
查看: 5249|回复: 0

[技巧手记] 教你用不同的首页模板制作帝国CMS多个动态首页

[复制链接]

469

主题

31

回帖

5509

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5509
发表于 2014-4-8 09:12:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
首先,咱们来分析一下首页index.php
  1. <?php
  2. require('e/class/connect.php');
  3. require('e/class/db_sql.php');
  4. require('e/class/functions.php');
  5. require('e/class/t_functions.php');
  6. require('e/data/dbcache/class.php');
  7. require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
  8. $link=db_connect();
  9. $empire=new mysqlquery();
  10. $pr=$empire->fetch1("select sitekey,siteintro from {$dbtbpre}enewspublic limit 1");
  11. //页面
  12. $pagetitle=htmlspecialchars($public_r['sitename']);
  13. $pagekey=htmlspecialchars($pr['sitekey']);
  14. $pagedes=htmlspecialchars($pr['siteintro']);
  15. $url="<a href="".$public_r[newsurl]."">".$fun_r['index']."</a>";//栏目导航
  16. $indextemp=GetIndextemp();//取得模板
  17. $string=DtNewsBq('indexpage',$indextemp,0);
  18. $string=str_replace('[!---newsnav--]',$url,$string);//位置导航
  19. $string=ReplaceSvars($string,$url,0,$pagetitle,$pagekey,$pagedes,$addr,0);
  20. $string=str_replace('[!---page.stats--]','',$string);
  21. echo stripSlashes($string);
  22. db_close();
  23. $empire=null;
  24. ?>
复制代码

主要的就是:
  1. $indextemp=GetIndextemp();//取得模板
  2. $string=DtNewsBq('indexpage',$indextemp,0);
复制代码


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




分析过后咱发现 GetIndextemp()是在e/class/functions.php 里面,我们搜索 GetIndextemp 在这下面增加
  1. //取得首页模板2
  2. function GetIndextemp1($mbid){
  3. global $empire,$dbtbpre,$public_r;
  4. $r=$empire->fetch1("select temptext from {$dbtbpre}enewsindexpage where tempid='".$mbid."'");
  5. return $r['temptext'];
  6. }
复制代码

然后搜索 DtNewsBq 在下面增加:
  1. //标签替换5
  2. function DtNewsBq1($classid,$indextext,$ecms=0){
  3. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  4. $cachetime=$ecms==1?$public_r['dtncachetime']:$public_r['dtcachetime'];
  5. $file=ECMS_PATH.'e/data/tmp/indexpage'.$classid.'.php';
  6. if($cachetime&&file_exists($file)){
  7. $filetime=filemtime($file);
  8. if(time()-$cachetime*60<=$filetime){
  9. ob_start();
  10. include($file);
  11. $string=ob_get_contents();
  12. ob_end_clean();
  13. $string=RepExeCode($string);//解析代码
  14. return $string;
  15. }}
  16. $indextext=stripSlashes($indextext);
  17. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  18. //替换标签
  19. $indextext=DoRepEcmsLoopBq($indextext);
  20. $indextext=RepBq($indextext);
  21. //写文件
  22. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  23. //读取文件内容
  24. ob_start();
  25. include($file);
  26. $string=ob_get_contents();
  27. ob_end_clean();
  28. $string=RepExeCode($string);//解析代码
  29. return $string;
  30. }
复制代码


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

  1. $indextemp=GetIndextemp1(1);//取得模板
  2. $string=DtNewsBq1('1',$indextemp,0);
复制代码

然后打开你的网址/index1.php 试试吧! 第2个首页可以打开了哦!


PS:本教程来自帝国CMS爱好者yecha官方网站www.52img.cn。感谢分享!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|PHPIN.NET ( 冀ICP备12000898号-14 )|网站地图

GMT+8, 2024-4-25 01:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表