700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 帝国自动生成html 帝国CMS7.2同步生成移动端HTML

帝国自动生成html 帝国CMS7.2同步生成移动端HTML

时间:2020-10-15 18:13:59

相关推荐

帝国自动生成html 帝国CMS7.2同步生成移动端HTML

1)后台添加变量:

变量名: mobile_tpl_id, 标识: 手机端模板ID, 写入缓存

2)要注意PC和移动端模板ID一定要一一对应,不对应的要修改数据库表的ID

封面模板 phome_enewsclasstemp和phome_enewsclasstemp_x(x为数字)

列表模板 phome_enewslisttemp和phome_enewslisttemp_x(x为数字)

内容模板 phome_enewsnewstemp和phome_enewsnewstemp_x(x为数字)

其他还有几个,用到的话,自己找下。

3)在/e/class/functions.php文件最后面添加进下面的代码,注意注意,下面的代码里出现的函数,把原程序里相同的函数都在函数名末尾加一个_bak。比如程序里原来的

function ListHtml($classid,$fields,$enews=0,$userlistr=””){

要改成

function ListHtml_bak($classid,$fields,$enews=0,$userlistr=””){

// 不方便传递参数的时候,使用全局变量,0为PC端,1为移动端

$current_port = 0;

function get_port(){

global $current_port;

return $current_port;

}

function set_port($val){

global $current_port;

$current_port = $val;

}

//刷新首页

function ReIndex(){

foreach(array(0,1) as $is_mobile){

set_port($is_mobile);

$indextemp=GetIndextemp();//取得模板

NewsBq($classid,$indextemp,1,0);

}

printerror("ReIndexSuccess","history.go(-1)");

}

//模板表转换

function GetTemptb($temptb){

global $public_r,$dbtbpre;

if(get_port()){

$tempid = $public_r['add_mobile_tpl_id'];

}else{

$tempid=$public_r['deftempid'];

}

if(!empty($tempid)&&$tempid!=1)

{

$en="_".$tempid;

}

return $dbtbpre.$temptb.$en;

}

//返回当前根目录

function eReturnTrueEcmsPath(){

if(get_port()){

$add_path = "/mobile/";

}else{

$add_path = "";

}

if(defined('ECMS_SELFPATH'))

{

return ECMS_SELFPATH.$add_path;

}

else

{

return ECMS_PATH.$add_path;

}

}

//写文件

function WriteFiletext($filepath,$string,$strip=TRUE){

global $public_r;

if($strip){

$string=stripSlashes($string);

}

$dir = dirname($filepath);

if(!file_exists($dir) && !mkdir($dir, true)){

exit("创建目录失败({$dir})");

}

if(!chmod($dir,0777)){

exit("修改目录权限失败({$dir})");

}

if(!file_put_contents($filepath, $string)){

exit("写入文件失败({$filepath})");

}

@chmod($filepath,0666);

}

//写文件

function WriteFiletext_n($filepath,$string){

WriteFiletext($filepath,$string,FALSE);

}

//生成列表

function ListHtml($classid,$fields,$enews=0,$userlistr=""){

foreach(array(1) as $is_mobile){

set_port($is_mobile);

ListHtml_bak($classid,$fields,$enews,$userlistr);

}

}

//生成内容文件

function GetHtml($classid,$id,$add,$ecms=0,$doall=0){

foreach(array(0,1) as $is_mobile){

set_port($is_mobile);

GetHtml_bak($classid,$id,$add,$ecms,$doall=0);

}

}

另有一处需要在函数中添加的代码

function ListHtml_bak > elseif($enews==4) >

$dopath=$userlistr['addpath'].$userlistr['filepath'];

$dolink=$public_r[newsurl].str_replace($userlistr['addpath'].'../../','',$dopath);

在这上面这两行的下面添加

if(get_port() == 1){

$realpath = realpath($dopath);

$dopath = str_replace(dirname(eReturnTrueEcmsPath()), eReturnTrueEcmsPath(), $realpath).'/';

}

经过上面的修改后,可同步生成首页,列表,文章,自定义列表。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。