帝国cms同一条信息使用不同的多个内容页模板伪静态实现教程

理论上可以实现一条信息使用无数个内容页模板,实现过程:

1、/e/action目录下新建bishun.php,内容如下:

<?php
require('../class/connect.php');
require('../class/db_sql.php');
require('../class/functions.php');
require('../class/t_functions.php');
require LoadLang('pub/fun.php');
require('../data/dbcache/class.php');
require('../data/dbcache/MemberLevel.php');
$link=db_connect();
$empire=new mysqlquery();
$classid=(int)$_GET['classid'];
$id=(int)$_GET['id'];
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$mid=$class_r[$classid]['modid'];
$tbname=$class_r[$classid]['tbname'];
//验证IP
eCheckAccessDoIp('showinfo');
if(!$classid||!$id||!$mid||!$tbname||InfoIsInTable($tbname))
{printerror('此信息不存在','',1,0,1);
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id' limit 1");
if(!$r['id']||$classid!=$r['classid'])
{printerror('此信息不存在','',1,0,1);
}
//外部链接
if($r['isurl'])
{$titleurl=$r['titleurl'];Header("Location:$titleurl");exit();
}
/*
//moreport
if(Moreport_ReturnMustDt())
{$class_r[$classid]['showdt']=2;
}
//是否支持动态内容页
if($class_r[$classid]['showdt']!=2)
{$titleurl=sys_ReturnBqTitleLink($r);Header("Location:$titleurl");exit();
}*/
//缓存
if($public_r['ctimeopen'])
{$public_r['usetotalnum']=0;
}
$ecms_tofunr=array();
$ecms_tofunr['cacheuse']=0;
$ecms_tofunr['cacheselfcid']=$classid;
$ecms_tofunr['cachetype']='textpage';
$ecms_tofunr['cacheids']=$classid.','.$id.','.$page;
$ecms_tofunr['cachepath']='empirecms';
$ecms_tofunr['cachedatepath']='ctext/bishun/'.date('Y/md',$r['truetime']);
$ecms_tofunr['cachetime']=$public_r['ctimetext'];
$ecms_tofunr['cachelasttime']=$public_r['ctimelast'];
$ecms_tofunr['cachelastedit']=$r['lastdotime'];
$ecms_tofunr['cacheopen']=Ecms_eCacheCheckOpen($ecms_tofunr['cachetime']);
$ecms_tofunr['cachehavedo']=0;
if($ecms_tofunr['cacheopen']==1&&!($r['groupid']||$class_r[$classid]['cgtoinfo']))
{$ecms_tofunr['cacheuse']=Ecms_eCacheOut($ecms_tofunr,2);if($ecms_tofunr['cacheuse']){//更新点击$empire->query("update {$dbtbpre}ecms_".$tbname." set onclick=onclick+1 where id='$id' limit 1");db_close();$empire=null;exit();}$ecms_tofunr['cachehavedo']=1;
}
//缓存
//副表
$finfor=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from {$dbtbpre}ecms_".$tbname."_data_".$r['stb']." where id='$r[id]' limit 1");
$r=array_merge($r,$finfor);
//权限
if($r['groupid']||$class_r[$classid]['cgtoinfo'])
{define('empirecms','wm_chief');define('PageCheckLevel','wm_chief');$check_tbname=$tbname;$check_infoid=$id;$check_classid=$classid;$check_path="../../";$checkinfor=$r;@include("../class/CheckLevel.php");
}
//缓存
if($ecms_tofunr['cacheopen']==1&&!$ecms_tofunr['cachehavedo'])
{$ecms_tofunr['cacheuse']=Ecms_eCacheOut($ecms_tofunr,2);if($ecms_tofunr['cacheuse']){//更新点击$empire->query("update {$dbtbpre}ecms_".$tbname." set onclick=onclick+1 where id='$id' limit 1");db_close();$empire=null;exit();}
}
//缓存
//存文本
if($emod_r[$mid]['savetxtf'])
{$stf=$emod_r[$mid]['savetxtf'];if($r[$stf]){$r[$stf]=GetTxtFieldText($r[$stf]);}
}
//初始值
$search="&classid=$classid&id=$id";
$line=1;
$start=0;
$page_line=6;//每页显示链接数
$offset=$page*$line;//总偏移量
$GLOBALS['navclassid']=$r[classid];
$GLOBALS['navinfor']=$r;
//取得内容模板
//$r[newstempid]=$r[newstempid]?$r[newstempid]:$class_r[$r[classid]][newstempid];
$r[newstempid]=29;
$newstemp_r=$empire->fetch1("select tempid,temptext,showdate from ".GetTemptb("enewsnewstemp")." where tempid='$r[newstempid]'");//替换模板变量
function DtGetHtml($add,$newstemp_r,$mid,$tbname,$line,$page_line,$start,$page,$search){global $public_r,$class_r,$class_zr,$class_tr,$fun_r,$empire,$dbtbpre,$emod_r,$level_r;//更新点击$empire->query("update {$dbtbpre}ecms_".$tbname." set onclick=onclick+1 where id='$add[id]' limit 1");$add['onclick']=$add['onclick']+1;//模板参数$newstemptext=$newstemp_r[temptext];$formatdate=$newstemp_r[showdate];//页面$pagetitle=ehtmlspecialchars($add[title]);$url=ReturnClassLink($add[classid]);//导航$newstemptext=DtInfo_ReplaceSvars($newstemptext,$url,$add[classid],$pagetitle,$add[keyboard],$pagetitle);//相关信息if(strstr($newstemptext,'[!--other.link--]')){$keyboardtext=GetKeyboard($add[keyboard],$add[keyid],$add[classid],$add[id],$class_r[$add[classid]][link_num]);}//分页字段$ptitle=$add['title'];$truepage='';$titleselect='';$expage='[!--empirenews.page--]';//分页符$pf=$emod_r[$mid]['pagef'];if($pf&&strstr($add[$pf],$expage))//有分页{$n_r=explode($expage,$add[$pf]);$thispagenum=count($n_r);//checkpagenoeCheckListPageNo($page,$line,$thispagenum);if($page<0||$page>$thispagenum-1){$page=0;}$add[$pf]=$n_r[$page];if($page){$ti_r=explode('[/!--empirenews.page--]',$n_r[$page]);if(count($ti_r)>=2){$ptitle=$ti_r[0];$add[$pf]=$ti_r[1];}else{$ptitle=$add['title'].'('.($page+1).')';}}//伪静态$pagefunr=eReturnRewriteInfoUrl($add['classid'],$add['id'],0);$pagefunr['repagenum']=0;//取得分页$truepage=InfoUsePage($thispagenum,$line,$page_line,$start,$page,$search,$pagefunr);//下拉式分页if(strstr($newstemptext,'[!--title.select--]')){for($j=0;$j<$thispagenum;$j++){$spurl=eReturnRewritePageLink($pagefunr,$j);if($j==0){$sptitle=$add[title];}else{$ti_r=explode('[/!--empirenews.page--]',$n_r[$j]);$sptitle=count($ti_r)>=2?$ti_r[0]:$add[title].'('.($j+1).')';}$select='';if($page==$j){$ptitle=$sptitle;$select=' selected';}$titleselect.='<option value="'.$spurl.'"'.$select.'>'.$sptitle.'</option>';}$titleselect='<select name="titleselect" onchange="self.location.href=this.options[this.selectedIndex].value">'.$titleselect.'</select>';}//下一页链接if($page==$thispagenum-1){$thisnextlink=eReturnRewritePageLink($pagefunr,0);}else{$thisnextlink=eReturnRewritePageLink($pagefunr,$page+1);}}else{//checkpagenoif($page!=0){printerror('ErrorUrl','history.go(-1)',1);}}//返回替换验证字符$docheckrep=ReturnCheckDoRepStr();if($add[newstext]){if(empty($public_r['dorepword'])&&$docheckrep[3]){$add[newstext]=ReplaceWord($add[newstext]);//过滤字符}if(empty($public_r['dorepkey'])&&$docheckrep[4]&&!empty($add[dokey]))//替换关键字{$add[newstext]=ReplaceKey($add['newstext'],$add['classid']);}if($public_r['opencopytext']){$add[newstext]=AddNotCopyRndStr($add[newstext]);//随机复制字符}}//变量$tempf=$emod_r[$mid]['tempf'];$fr=explode(',',$tempf);$fcount=count($fr)-1;//变量替换$newstempstr=$newstemptext;//模板for($i=1;$i<$fcount;$i++){$f=$fr[$i];$value=$add[$f];if($f=='downpath')//下载地址{if(strstr($newstemptext,'[!--downpath--]')){$value=ReturnDownSoftHtml($add);}}elseif($f=='onlinepath')//观看地址{if(strstr($newstemptext,'[!--onlinepath--]')){$value=ReturnOnlinepathHtml($add);}}elseif($f=='morepic')//图片集{if(strstr($newstemptext,'[!--morepic--]')){$value=ReturnMorepicpathHtml($add);}}elseif($f=='newstime')//时间{if(strstr($newstemptext,'[!--newstime--]')){$value=date($formatdate,$value);}}elseif($f=='befrom')//信息来源{if($docheckrep[1]&&strstr($newstemptext,'[!--befrom--]')){$value=ReplaceBefrom($value);}}elseif($f=='writer')//作者{if($docheckrep[2]&&strstr($newstemptext,'[!--writer--]')){$value=ReplaceWriter($value);}}elseif($f=='titlepic')//标题图片{if(empty($value)){$value=$public_r[newsurl].'e/data/images/notimg.gif';}}elseif($f=='title')//标题{}else//正常字段{if(!strstr($emod_r[$mid]['editorf'],','.$f.',')){if(strstr($emod_r[$mid]['tobrf'],','.$f.','))//加br{$value=nl2br($value);}if(!strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//去除html{$value=RepFieldtextNbsp(ehtmlspecialchars($value));}}}$newstempstr=str_replace('[!--'.$f.'--]',$value,$newstempstr);}//固定变量$newstempstr=str_replace('[!--id--]',$add[id],$newstempstr);$newstempstr=str_replace('[!--classid--]',$add[classid],$newstempstr);$newstempstr=str_replace('[!--class.name--]',$class_r[$add[classid]][classname],$newstempstr);$newstempstr=str_replace('[!--ttid--]',$add[ttid],$newstempstr);$newstempstr=str_replace('[!--tt.name--]',$class_tr[$add[ttid]][tname],$newstempstr);$newstempstr=str_replace('[!--tt.url--]',sys_ReturnBqInfoTypeUrl($add['ttid']),$newstempstr);$newstempstr=str_replace('[!--onclick--]',$add[onclick],$newstempstr);$newstempstr=str_replace('[!--userfen--]',$add[userfen],$newstempstr);$newstempstr=str_replace('[!--username--]',$add[username],$newstempstr);//带链接的用户名if($add[ismember]==1&&$add[userid]){$newstempstr=str_replace('[!--linkusername--]',"<a href='".$public_r[newsurl]."e/space/?userid=".$add[userid]."' target=_blank>".$add[username]."</a>",$newstempstr);}else{$newstempstr=str_replace('[!--linkusername--]',$add[username],$newstempstr);}$newstempstr=str_replace('[!--userid--]',$add[userid],$newstempstr);$newstempstr=str_replace('[!--other.link--]',$keyboardtext,$newstempstr);$newstempstr=str_replace('[!--news.url--]',$public_r[newsurl],$newstempstr);$newstempstr=str_replace('[!--plnum--]',$add[plnum],$newstempstr);$newstempstr=str_replace('[!--totaldown--]',$add[totaldown],$newstempstr);$newstempstr=str_replace('[!--keyboard--]',$add[keyboard],$newstempstr);//链接$titleurl=sys_ReturnBqTitleLink($add);$newstempstr=str_replace('[!--titleurl--]',$titleurl,$newstempstr);$newstempstr=str_replace('[!--page.stats--]','',$newstempstr);$classurl=sys_ReturnBqClassname($add,9);$newstempstr=str_replace('[!--class.url--]',$classurl,$newstempstr);//下一篇if(strstr($newstemptext,'[!--info.next--]')){$next_r=$empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id>$add[id] and classid='$add[classid]' order by id limit 1");if(empty($next_r[id])){$infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>";}else{//链接$nexttitleurl=sys_ReturnBqTitleLink($next_r);$infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>";}$newstempstr=str_replace('[!--info.next--]',$infonext,$newstempstr);}//上一篇if(strstr($newstemptext,'[!--info.pre--]')){$next_r=$empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$add[id] and classid='$add[classid]' order by id desc limit 1");if(empty($next_r[id])){$infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>";}else{//链接$nexttitleurl=sys_ReturnBqTitleLink($next_r);$infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>";}$newstempstr=str_replace('[!--info.pre--]',$infonext,$newstempstr);}//投票if(strstr($newstemptext,'[!--info.vote--]')){$myvotetext=sys_GetInfoVote($add[classid],$add[id]);$newstempstr=str_replace('[!--info.vote--]',$myvotetext,$newstempstr);}//评分if(strstr($newstemptext,'[!--pinfopfen--]')){$pinfopfen=$add[infopfennum]?round($add[infopfen]/$add[infopfennum]):0;$newstempstr=str_replace('[!--pinfopfen--]',$pinfopfen,$newstempstr);$newstempstr=str_replace('[!--infopfennum--]',$add[infopfennum],$newstempstr);}$string=$newstempstr;//替换变量$string=str_replace('[!--p.title--]',strip_tags($ptitle),$string);$string=str_replace('[!--next.page--]',$thisnextlink,$string);$string=str_replace('[!--page.url--]',$truepage,$string);$string=str_replace('[!--title.select--]',$titleselect,$string);return $string;
}if(empty($newstemp_r['tempid']))
{printerror('ErrorUrl','',1);
}
//页面支持标签
if($public_r['dtncanbq'])
{$newstemp_r[temptext]=DtNewsBq('text'.$newstemp_r[tempid],$newstemp_r[temptext],1);
}
else
{if($public_r['searchtempvar']){$newstemp_r[temptext]=ReplaceTempvar($newstemp_r[temptext]);}
}
$string=DtGetHtml($r,$newstemp_r,$mid,$tbname,$line,$page_line,$start,$page,$search);
//缓存
if($ecms_tofunr['cacheopen']==1)
{Ecms_eCacheIn($ecms_tofunr,stripSlashes($string));
}
else
{echo stripSlashes($string);
}
//缓存
db_close();
$empire=null;
?>

2、增加内容页模板,模板内容与正常内容页模板一样调用,新建完成后记住内容页模板id。

3、增加伪静态规则:rewrite ^/bishun/zi-([0-9]+)\.html$ /e/action/bishun.php?classid=5&id=$1 last;

演示地址就是使用1个内容的信息用5个页面调出

https://www.gushichi.com/bishun/zi-2606.html

https://www.gushichi.com/wubi/zi-2606.html

https://www.gushichi.com/wuxing/zi-2606.html

https://www.gushichi.com/bushou/zi-2606.html

https://www.gushichi.com/duyin/zi-2606.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/64883.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Go1.21.0 到 Go1.23.0 的改动,向前兼容性和toolchain规则,Go1.21.0,必须升级你的Go啦

Go各版本Release Note Go1.21.0 2023-08-08 https://go.dev/doc/go1.21 内置方法 min & max&#xff1a;返回一个序列中的最大值最小值。 https://go.dev/ref/spec#Min_and_max clear&#xff1a;清空map和slice。 https://go.dev/ref/spec#Clear 标准库 log/slo…

Python:使用PyInstaller打包

本文所讲仅为独立的项目文件夹下如何进行打包&#xff0c;不涉及存在依赖关系的多个文件夹共同打包。 项目结构示例 D:/└── myproject└── my_project├── main.py├── module1.py└── other_files...项目文件夹&#xff1a;my_project主程序文件&#xff1a;main.…

Unity中的委托和事件(UnityAction、UnityEvent)

委托和事件 &#x1f392;什么是委托&#xff0c;委托的关键字是Delegate&#xff0c;委托是一种函数的容器&#xff0c;运行将函数做为变量来进行传递 通过Delegate关键字我们声明了一个无参无返回的委托&#xff0c;通过这个委托我们可以存储无参无返回的函数 public deleg…

sh cmake-linux.sh -- --skip-license --prefix = $MY_INSTALL_DIR

本文来自天工AI --------- 命令用于安装CMake的脚本&#xff0c;其中--skip-license参数表示跳过许可协议的显示&#xff0c;--prefix参数指定了CMake的安装目录。$MYINSTALLDIR是一个环境变量&#xff0c;应该在运行命令之前设置为您想要安装CMake的目录。 -------- sh xx…

面试真题 | 金山 C++ [20241218]

文章目录 @[toc]1.c++程序的内存分布C++程序的内存分布面试官的追问及回答2.堆和栈的区别堆和栈的区别1. 管理方式2. 内存分配和释放3. 内存大小和生命周期4. 访问权限面试官的追问及回答3.内存泄漏怎么办内存泄漏的处理方法面试官的追问及回答4.智能指针,哪几种智能指针及其种…

呼入机器人:24小时客户服务的未来趋势

呼入机器人&#xff1a;24小时客户服务的未来趋势 作者&#xff1a;开源大模型智能呼叫中心系统FreeAICC&#xff0c;Github&#xff1a;https://github.com/FreeIPCC/FreeAICC 在当今快节奏的商业环境中&#xff0c;客户服务已成为企业竞争的核心要素之一。随着人工智能技术…

使用计算机创建一个虚拟世界

创建一个虚拟世界是一项复杂而多方面的工作&#xff0c;它涉及多个领域的知识&#xff0c;包括计算机图形学、编程、物理模拟、声音设计、艺术设计等。以下是创建虚拟世界的基本步骤和工具建议&#xff1a; 1. 确定虚拟世界的目标和范围 目标&#xff1a;明确这个虚拟世界的用…

uniapp v-tabs修改了几项功能,根据自己需求自己改

根据自己的需求都可以改 这里写自定义目录标题 1.数组中的名字过长&#xff0c;导致滑动异常2.change 事件拿不到当前点击的数据&#xff0c;通过index在原数组中查找得到所需要的id 各种字段麻烦3.添加指定下标下新加红点显示样式 1.数组中的名字过长&#xff0c;导致滑动异常…

CAD xy坐标标注(跟随鼠标位置实时移动)——C#插件实现

效果如下&#xff1a; &#xff08;使用方法&#xff1a;命令行输入 “netload” 加载此dll插件&#xff0c;然后输入“zbbz”运行&#xff0c;选择文件夹即可。支持字体大小变化&#xff0c;输入“zbbd”可设置坐标字体变大或缩小的倍数&#xff09; 部分代码如下&#xff1a;…

vue项目中使用ag-grid

我这个项目中使用原因&#xff1a; 支持大数据量数据&#xff0c;滑动页面不会有白屏现象可对当前列表中数据进行过滤 安装依赖 ag-grid-vueag-grid-community 我这里使用的社区版ag-grid-community/locale 中文配置依赖 main.js import "ag-grid-community/styles/ag-gr…

【C#】实现Json转Lua (Json2Lua)

关键词: C#、JsonToLua、Json2Lua、对象序列化Lua 前提需引入NewtonsofJson&#xff0c;引入方法可先在Visual Studio 2019 将Newtonsoft.Json.dll文件导入Unity的Plugins下。 Json格式字符串转Lua格式字符串&#xff0c;效果如下&#xff1a; json字符串 {"1": &q…

Redis 7.x如何安装与配置?保姆级教程

大家好&#xff0c;我是袁庭新。最新写了一套最新版的Redis 7.x企业级开发教程&#xff0c;今天先给大家介绍下Redis 7.x如何在Linux系统上安装和配置。 1 Redis下载与安装 使用非关系型数据库Redis必须先进行安装配置并开启Redis服务&#xff0c;然后使用对应客户端连接使用…

Redis篇--常见问题篇6--缓存一致性1(Mysql和Redis缓存一致,更新数据库删除缓存策略)

1、概述 在使用Redis作为MySQL的缓存层时&#xff0c;缓存一致性问题是指Redis中的缓存数据与MySQL数据库中的实际数据不一致的情况。这可能会导致读取到过期或错误的数据&#xff0c;从而影响系统的正确性和用户体验。 为了减轻数据库的压力&#xff0c;通常读操作都是先读缓…

代码加入SFTP JAVA ---(小白篇3)

在 Java 中&#xff0c;您可以使用 JSch&#xff08;Java Secure Channel&#xff09;库 来连接和操作 SFTP 服务器。以下是一个完整的示例代码&#xff0c;展示如何使用 Java 接入 SFTP 服务器并上传文件。 1.服务器上加入SFTP------(小白篇 1) 2.加入SFTP 用户------(小白篇…

leetcode之hot100---240搜索二维矩阵II(C++)

思路一&#xff1a;通过遍历主对角线上元素判断查找方向 主对角线遍历&#xff1a; 遍历主对角线上的每个元素&#xff08;matrix[i][i]&#xff09;&#xff0c;其中 i 的范围是 [0, min(m, n) - 1]。如果目标值小于当前主对角线元素&#xff0c;说明目标值可能在当前元素的左…

【Nginx-4】Nginx负载均衡策略详解

在现代Web应用中&#xff0c;随着用户访问量的增加&#xff0c;单台服务器往往难以承受巨大的流量压力。为了解决这一问题&#xff0c;负载均衡技术应运而生。Nginx作为一款高性能的Web服务器和反向代理服务器&#xff0c;提供了多种负载均衡策略&#xff0c;能够有效地将请求分…

git remote -v(--verbose)显示你的 Git 仓库配置的远程仓库的详细信息

git remote -v 是一个 Git 命令&#xff0c;用于显示你的 Git 仓库配置的远程仓库的详细信息。 当你执行 git remote -v 命令时&#xff0c;你会看到类似以下的输出&#xff1a; origin https://github.com/your-username/your-repo.git (fetch) origin https://github.com…

《Java 与 Deeplearning4j:开启深度学习高效训练之旅》

在当今科技飞速发展的时代&#xff0c;深度学习无疑是人工智能领域的一颗璀璨明珠。Java 作为一种广泛应用的编程语言&#xff0c;与 Deeplearning4j 框架的结合&#xff0c;为开发者们开辟了一条在深度学习领域大展身手的新路径。那么&#xff0c;如何在 Java 中高效地使用 De…

MySQL 基础:开启数据库之旅

MySQL 基础&#xff1a;开启数据库之旅 在当今数字化的时代&#xff0c;数据扮演着至关重要的角色&#xff0c;而数据库管理系统则是存储、管理和操作这些数据的强大工具。MySQL 作为一款广受欢迎的开源关系型数据库管理系统&#xff0c;被广泛应用于各类网站、应用程序以及企业…

递归读取指定目录下的文件

序言 需要读取sftp服务器上符合指定的文件名正则的文件列表&#xff0c;目前想到的最好的办法就是递归。 我这里引入的依赖是&#xff1a; <!-- jsch-sftp连接 --><dependency><groupId>com.jcraft</groupId><artifactId>jsch</artif…