dede织梦手机端静态HTML生成之-移动静态列表

overme5个月前 (10-17)网页设计212
1.复制文件dede/makehtml_list.php,重命名为makehtml_list_m.php

2.打开makehtml_list_m.php,找到最后一行

include DedeInclude(‘templets/makehtml_list.htm’);

修改为

include DedeInclude(‘templets/makehtml_list_m.htm’);

3.复制文件dede/templets/makehtml_list.htm 重命名为makehtml_list_m.htm ,打开后修改第10行

<form name=”form1″ action=”makehtml_list_action.php” method=”get” target=’stafrm’>

修改为

<form name=”form1″ action=”makehtml_list_action_m.php” method=”get” target=’stafrm’>

4.复制dede/makehtml_list_action.php 重命名makehtml_list_action_m.php

require_once(DEDEINC.”/arc.listview.class.php”);

修改为

require_once(DEDEINC.”/arc.listwapview.class.php”);

5.进入include目录,复制arc.listview.class.php 重命名为arc.listwapview.class.php,并打开该文

if(!file_exists($tempfile))
{

            $tempfile = $GLOBALS[‘cfg_basedir’].$GLOBALS[‘cfg_templets_dir’].”/”.$GLOBALS

[‘cfg_df_style’].”/list_default.htm”;

}

if(!file_exists($tempfile)||!is_file($tempfile))

{

          echo “模板文件不存在,无法解析文档!”;

          exit();

}

替换为

$tempfile = $GLOBALS[‘cfg_basedir’].$GLOBALS[‘cfg_templets_dir’].”/”.$GLOBALS

[‘cfg_df_style’].”/list_default_m.htm”;

变更实现的功能是定义静态列表文件的模板为default目录下的list_default_m.htm文件,因此default

目录下需建立该模板问题件。
以上代码实现的固定模板文件,如果需要根据栏目不同进行变更,可以综合使用str_replace函数。

6. 修改栏目储存目录,在658-659行后面添加代码,生成的栏目文件保存在文件夹“m”下面

$typedir = MfTypedir(‘/m/’.$typedir);

修改

function GetMakeFileRule($typeid,$wname,$typedir,$defaultname,$namerule2)

    {

     $typedir = MfTypedir(‘/m/’.$typedir);

     if($wname==’index’)

该文件中有几处创建目录的代码

CreateDir(MfTypedir($this->Fields[‘typedir’]));

修改为:CreateDir(MfTypedir(‘/m/’.$this->Fields[‘typedir’]));

代码345-371行是把list第一页复制为首页index.html的,修改354行修改复制保存路径,在$this-

>Fields[‘typedir’])前面添加’/m/’. 如下面10行所示

if($startpage==1)

{

//如果列表启用封面文件,复制这个文件第一页

if($this->TypeLink->TypeInfos[‘isdefault’]==1

&& $this->TypeLink->TypeInfos[‘ispart’]==0)

{

$onlyrule = $this->GetMakeFileRule($this->Fields[‘id’],”list”,$this->Fields[‘typedir’],”,

$this->Fields[‘namerule2’]);

$onlyrule = str_replace(“{page}”,”1″,$onlyrule);

$list_1 = $this->GetTruePath().$onlyrule;

$murl = MfTypedir(‘/m/’.$this->Fields[‘typedir’]).’/’.$this->Fields[‘defaultname’];

//如果启用远程发布则需要进行判断

if($cfg_remote_site==’Y’&& $isremote == 1)

{

//分析远程文件路径

$remotefile = $murl;

$localfile = ‘..’.$remotefile;

$remotedir = preg_replace(‘/[^/]*.html/’, ”,$remotefile);

//不相等则说明已经切换目录则可以创建镜像

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, ‘acii’);

}

$indexname = $this->GetTruePath().$murl;

copy($list_1,$indexname);

}

}
return $murl;
}

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。