欢迎来到六久阁织梦模板网!
织梦后台发布文章后自动生成手机静态页或MIP静态页

织梦后台发布文章后自动生成手机静态页或MIP静态页

浏览次数: 0

作者: 六久阁织梦模板网

信息来源: 六久阁

更新日期: 2018-08-31

文章简介

第一步:找到织梦include目录下的arc.archives.class.php ,应该在286行吧!搜索function MakeHtml 函数即可 /** *生成静态HTML * *@accesspublic *@paramint$isremote是否远程 *@returnstring */ functionMakeHtml($isremote=0){ 找到这个函数的结尾,这一

  • 正文开始
  • 热门文章

  第一步:找到织梦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端 那么重复上面一次,改下名字即可


织梦二次开发QQ群

本站客服QQ号:862782808(点击左边QQ号交流),群号(383578617) DedeCMS织梦教程QQ群 如果您有任何织梦问题,请把问题发到群里,阁主将为您写解决教程!

转载请注明: 织梦模板 » 织梦后台发布文章后自动生成手机静态页或MIP静态页

  • 织梦dedecms手机站m目录下不生成index.html实现动态更新
    阅读
    用 织梦建站 会手机站首页不更新的苦恼,每次 PC 更新,要去删除 m 目录下的 index.html ,手机站首页才会更新,这样很麻烦,通过以下修改,让手机站首页是动态的,不生成 index.html , PC 端更新后,手机端首页自动更新。 把 \m\index.php 里面的 $row[sho...
  • 织梦Fatal error: Call to undefined function make_hash() in /dede/sys_info.php on line 201的解决方法
    阅读
    织梦系统安装好后,进入后台,出现Fatal error: Call to undefined function make_hash() in /dede/sys_info.php on line 201 一般出现这个问题是因为升级网站引起的。我们可以直接把错误提示这段代码删除或者屏蔽就行了。 打开/dede/sys_info.php,找到201...
  • 织梦Dedecms 5.7 火车头采集免登陆发布接口适配PHP7.X插件
    阅读
    最近有粉丝说,之前用的火车头发布文章时,用免登陆接口在PHP7.0环境中显示空白,于是今天抽空更新了一下插件(话说,DedeCms早期版本无法在PHP7.X运行,用最新版的!),那么接下来的代码就是插件发布模块无须变更,只需要变更接口插件就可以了 ?php/*/////...
  • 织梦dedecms系统多城市分站功能开发思路
    阅读
    当前很多人用织梦dedecms系统建站,多城市分站对地方性长尾关键词和全国市场的推广有着很大的帮助,今天和大家分享下如何实现织梦dedecms系统多城市分站功能。 方法/步骤 织梦dede城市分站有三种方法: 第一种是建立N多个模板,有多少个城市建立多少个模板,...
  • 织梦dedecms提交自定义表单后发送到指定邮箱
    阅读
    网上很多教程都是用 dedecms 自带的邮件库发送邮件,而且是写死要发送的字段内容,今天我们用 phpmailer 来给站长发送自定义表单提交的数据到指定邮箱上 (QQ 邮箱, 163 邮箱都可以 ) ,不写死任何东西,有什么字段就提交发送什么字段。 操作之前,我们要先...
  • 织梦5.7火车头免登陆文章发布模块采集后自动更新织梦整站
    阅读
    织梦5.7火车头免登陆文章发布模块采集后自动更新织梦整站详细步骤: 1、下载文档后,把DedeCMS免登陆接口文章发布模块DedeCMS 5.7 免登陆接口文章发布模块.wpm复制到火车头采集规则文件夹Module下; 2、选择您网站对应的接口文件.如您网站是gbk编码,请选择 g...
  • dedecms织梦ckplayer视频播放器插件详细安装教程
    阅读
    织梦 ckplayer 视频播放器插件安装步骤: 第一步、下载安装插件。下载地址:点击此处 将下载下来的压缩包中的相应编码的模块文件解压出来再上传到织梦程序的 data/module/ 文件夹内或者直接在后台模块管理菜单里面选择上传新模块安装即可。如下图: 1.1 )上...
  • 织梦采集侠破解版自动采集触发教程24小时触发自动审核自动更新
    阅读
    最新采集侠V2.9.2破解版,可以在网站进行全自动数据采集,采集侠破解版可以帮助用户快速提升自己网站的Seo排名。 织梦采集侠是一款基于dedecms的一套根据关键词自动采集,无须编写复杂的采集规则,自动伪原创,自动发布内容的绿色插件。简单配置好后能实现24...
  • 织梦dedecms网站添加打赏功能
    阅读
    有时我们看到别人家的织梦dedecms网站有打赏功能,是不是羡慕嫉妒恨呢?今天我来给大家讲讲织梦网站怎么添加支付宝、微信打赏功能。 二、首先登陆畅言后台(没有畅言账号的首先注册账号) 三、进入后台,找到实验室--打赏 四、设置配置信息,保存。 五、复制...
  • 织梦火车头采集免登陆接口采集文章后自动更新栏目、首页、文章页,实现自动化采集
    阅读
    最近用织梦dedecms程序采集文章时候,发现每次采集都要去后台更新一下文章、栏目、上下篇以及首页,操作起来真心麻烦,后面在网上收集了一些代码以及经过自己调试,发现居然可以自动更新文章页以及栏目、首页。真心爽,这样子就能稳稳的挂机采集了哈。这是免...
收藏此文 打赏本站

如本文对您有帮助,就请六久阁织梦模板网抽根烟吧!

  • 支付宝打赏
    支付宝扫描打赏
    微信打赏
    微信扫描打赏
织梦dedecms最常用标签调用大全
« 上一篇 2018年08月31日
织梦mip改造方法及改造心得分享
下一篇 » 2018年08月30日

精彩评论

有问题在这里提问,阁主会为你解决!
  • 全部评论(0
    还没有评论,快来抢沙发吧!
推荐织梦插件更多
更新时间:2018-05-11

人已经看过了!

更新时间:2019-05-08

人已经看过了!

更新时间:2019-08-01

人已经看过了!

更新时间:2018-05-25

人已经看过了!

更新时间:2019-07-11

人已经看过了!

更新时间:2017-09-11

人已经看过了!

更新时间:2019-10-19

人已经看过了!

推荐精品模板更多