前提,把电脑端和手机端的模板都做好,注意模板命名都要一样
1、增加系统参数手机模板路径和手机文件夹路径,注意模板是和电脑端的都在templets下面,增加后再 系统》系统基本参数查看
INSERT INTO `dede_sysconfig` (`aid`,`varname`,`info`,`value`,`type`,`groupid`) VALUES ('832','cfg_sjarcdir','手机路径','3g','string','1'); INSERT INTO `dede_sysconfig` (`aid`,`varname`,`info`,`value`,`type`,`groupid`) VALUES ('832','cfg_sj_style','手机模板','sj','string','1');
2、先调试生成文章(这个比较简单)
打开include》arc.archives.class.php
大概351行吧 function MakeHtml 这个函数的结尾找到
$this->dsql->ExecuteNoneQuery("Update `dede_archives` SET ismake=1 WHERE id='".$this->ArcID."'"); return $this->GetTrueUrl($filename);
改成
$this->dsql->ExecuteNoneQuery( "Update `dede_archives` SET ismake=1 WHERE id='" . $this->ArcID . "'" ); $returl = $this->GetTrueUrl( $filename ); $this->MakeWapHtml( $isremote ); return $returl;
意思就是再执行以下另外一个函数MakeWapHtml,然后我们在函数结束 下面增加另外一个函数MakeWapHtml
核心位置有3处,在下面函数里面有
function MakeWapHtml($isremote=0) { global $cfg_df_style,$cfg_arcdir,$cfg_sj_style,$cfg_sjarcdir;//核心位置这里需要增加2个系统参数下面会调用 $tempfile = $this->GetTempletFile(); $tempfile = str_replace('/' . $cfg_df_style . '/','/' . $cfg_sj_style . '/',$tempfile);//这里替换下电脑端模板的路径为增加的路劲参数 if(!file_exists($tempfile) || !is_file($tempfile)) { }else{ global $cfg_remote_site,$fileFirst; if($this->IsError) { return ''; } $this->Fields["displaytype"] = "st"; //预编译$th $this->dtp->LoadTemplate($tempfile); $this->TempSource = $this->dtp->SourceString; $this->ParAddTable(); $this->ParseTempletsFirst(); $this->Fields['senddate'] = empty($this->Fields['senddate'])? '' : $this->Fields['senddate']; $this->Fields['title'] = empty($this->Fields['title'])? '' : $this->Fields['title']; $this->Fields['arcrank'] = empty($this->Fields['arcrank'])? 0 : $this->Fields['arcrank']; $this->Fields['ismake'] = empty($this->Fields['ismake'])? 0 : $this->Fields['ismake']; $this->Fields['money'] = empty($this->Fields['money'])? 0 : $this->Fields['money']; $this->Fields['filename'] = empty($this->Fields['filename'])? '' : $this->Fields['filename']; //分析要创建的文件名称 $filename = GetFileNewName( $this->ArcID,$this->Fields['typeid'],$this->Fields['senddate'], $this->Fields['title'],$this->Fields['ismake'],$this->Fields['arcrank'], $this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields['money'],$this->Fields['filename'] ); $filename=str_replace($cfg_arcdir .'/',$cfg_sjarcdir . $cfg_arcdir .'/',$filename); //这里把生成文件的路劲增加一个手机端的路劲,就是上面增加的参数,注意手机端如果是m 系统参数那里就填/m,然后会自动生成和电脑端一样的路劲只是增加一个m $filenames = explode(".", $filename); $this->ShortName = $filenames[count($filenames)-1]; if($this->ShortName=='') $this->ShortName = 'html'; $fileFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filename); $this->Fields['namehand'] = basename($fileFirst); $filenames = explode("/", $filename); $this->NameFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filenames[count($filenames)-1]); if($this->NameFirst=='') { $this->NameFirst = $this->arcID; } //获得当前文档的全名 $filenameFull = GetFileUrl( $this->ArcID,$this->Fields['typeid'],$this->Fields["senddate"], $this->Fields["title"],$this->Fields["ismake"], $this->Fields["arcrank"],$this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields["money"],$this->Fields['filename'], $this->TypeLink->TypeInfos['moresite'],$this->TypeLink->TypeInfos['siteurl'],$this->TypeLink->TypeInfos['sitepath'] ); $this->Fields['arcurl'] = $this->Fields['fullname'] = $filenameFull; //对于已设置不生成HTML的文章直接返回网址 if($this->Fields['ismake']==-1 || $this->Fields['arcrank']!=0 || $this->Fields['money']>0 || ($this->Fields['typeid']==0 && $this->Fields['channel'] != -1) ) { return $this->GetTrueUrl($filename); } //循环生成HTML文件 else { for($i=1;$i<=$this->TotalPage;$i++) { if($this->TotalPage > 1) { $this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']); if($i>1) $this->Fields['title'] = $this->Fields['tmptitle']."($i)"; } if($i>1) { $TRUEfilename = $this->GetTruePath().$fileFirst."_".$i.".".$this->ShortName; } else { $TRUEfilename = $this->GetTruePath().$filename; } $this->ParseDMFields($i,1); if(!is_dir(dirname($TRUEfilename))) { mkdir(dirname($TRUEfilename), 0777, true); } $this->dtp->SaveTo($TRUEfilename); //如果启用远程发布则需要进行判断 if($cfg_remote_site=='Y' && $isremote == 1) { //分析远程文件路径 $remotefile = str_replace(DEDEROOT, '', $TRUEfilename); $localfile = '..'.$remotefile; //创建远程文件夹 $remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile); $this->ftp->rmkdir($remotedir); $this->ftp->upload($localfile, $remotefile, 'ascii'); } } } $this->TempSource==''; } }
3、下面是首页的,首页的我找了好久,在织梦后台默认的目录里面 即dede
找到dedetag.class.php里面的
function IncludeFile函数的下面的第一行
global $cfg_df_style;
改成
global $cfg_df_style,$cfg_sj_style;
即增加一个系统函数下面要调用,再找到就上面的下面几行 大概在1027行
else { return "无法在这个位置找到: $filename"; }
在上面增加,
else if(file_exists(DEDEROOT.'/templets'.$cfg_sj_style.'/'.$filename) ) { $okfile = DEDEROOT.'/templets'.$cfg_sj_style.'/'.$filename; }
上面的生成后发现是调用的电脑端的头部和底部
那么我们可以先把手机端的
{dede:include filename="head.htm"/}
改成
{dede:include filename="/sj/head.htm"/}即可!
列表页
有2个文件要改arc.listview.class.php ,arc.sglistview.class.php
首先找到
function CountRecord()
改成
function CountRecord($iswap=0)
然后再这个函数里面找到
if ( defined('DEDEMOB') )
再这个函数后面增加一个函数
if($iswap==1){ $tempfile = str_replace('/'.$GLOBALS['cfg_df_style'].'/','/'.$GLOBALS['cfg_sj_style'].'/',$tempfile); }
然后就是 function MakeHtml
改成
function MakeHtml($startpage=1,$makepagesize=0)
并且在函数结束为止
改
$reurl=$murl; $this->MakeWapHtml($startpage, $makepagesize, $isremote); return $reurl;
就是再执行一次
function MakeWapHtml($startpage=1, $makepagesize=0, $isremote=0)
这个函数里面内容复制上面即可
然后 function MakePartTemplets()
结尾处增加
$returl=$this->GetTrueUrl($makeUrl); $this->MakeWapPartTemplets(); return $returl;
function MakeWapPartTemplets() 复制上面的函数
里面的模板进行替换
好吧! 上面只是增强我的记忆!
改天下一个完整版织梦同时生产文件的教程