第一步:找到织梦include目录下的arc.archives.class.php ,应该在286行吧!搜索function MakeHtml 函数即可
/** * 生成静态HTML * * @access public * @param int $isremote 是否远程 * @return string */ function MakeHtml( $isremote = 0 ) {
找到这个函数的结尾,这一段:
$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; }
第二步,复制mip或者手机端模板文件到电脑端模板目录下,举例
电脑端模板为
templets
default
那么把手机端或者mip端模板放入后就是
templets
default
mip
这里需要注意下的是我mip端新增了函数{dede:field.body function='replaceurl(@me)'/} 但是这个函数的执行方法是在mip端的文件里面,所以需要把mip端的函数复制一份到同样的pc端文件中(手机没有新增函数就忽略);
切记只要手机活动mip端独有的函数,都要在pc端使用一份,不然无法生成成功。
切记,如果手机或者mip模板采用了{dede:include filename="head.htm"/}标签
那么请改为{dede:include filename="mip/head.htm"/} mip改为自己的目录
第三步,在第一步修改函数的后面增加函数
注意看里面的注释,有2处
function MakeWapHtml( $isremote = 0 ) { $tempfile = $this->GetTempletFile(); $tempfile = str_replace( 'default', 'mip', $tempfile );//这里是把你电脑端的生成模板风格改成手机端或者mip端的风格,就是第二部要你放入的文件,你照着第二步的填即可,如果填错,或获取默认的 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' ]; //分析要创建的文件名称www.lol9.cn $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 = '/mip' . $filename;//改成你的mip端或者手机端目录 //下面这里是系统参数生成的文档HTML默认保存路径,如果你的是什么就改成什么,然后看你mip端在哪个路径,默认填错是系统电脑端的目录没事 $filename = str_replace( '/mip/html/', '/mip/html/', $filename ); $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 == ''; } }
好了 如果要同时手机端和mip端 那么重复上面一次,改下名字即可
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明: 织梦后台发布文章后自动生成手机静态页或MIP静态页