帝国自动生成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).'/';

}

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值