织梦火车头采集自动生成首页栏目页

织梦使用火车头采集器采集数据,发布文档后是不会自动生成首页、上下篇、栏目页的,我们可以给织梦添加自动生成代码来实现

实现教程

打开 /dede/inc/inc_archives_functions.php 最下面加入3个函数(按需求添加,不一定全加)

/火车头采集自动更新主页/

function MakeIndex()

{

global $dsql,$cfg_basedir,$cfg_templets_dir,$cfg_df_style;

require_once(DEDEINC.'/arc.partview.class.php');

$envs = $_sys_globals = array();

$envs['aid'] = 0;

$pv = new PartView();

$row = $pv->dsql->GetOne('SELECT * FROM `#@__homepageset`');

$templet = str_replace("{style}", $cfg_df_style, $row['templet']);

$homeFile = dirname(__FILE__).'/../'.$row['position'];

$homeFile = str_replace("//", "/", str_replace("\\", "/", $homeFile));

$fp = fopen($homeFile, 'w') or die("无法更新网站主页到:$homeFile 位置");

fclose($fp);

$tpl = $cfg_basedir.$cfg_templets_dir.'/'.$templet;

if(!file_exists($tpl))

{

$tpl = $cfg_basedir.$cfg_templets_dir.'/default/index.htm';

if(!file_exists($tpl)) exit("无法找到主页模板:$tpl ");

}

$GLOBALS['_arclistEnv'] = 'index';

$pv->SetTemplet($tpl);

$pv->SaveToHtml($homeFile);

$pv->Close();

}

/*火车头采集自动更新栏目*/

function MakeParentType($typeid)

{

global $dsql;

$typediarr = array();

array_push($typediarr,$typeid);

$row3 = $dsql->GetOne("Select reid,topid From `#@__arctype` where id=".$typeid);

if(!in_array($row3['reid'],$typediarr) and $row3['reid']!=0) array_push($typediarr,$row3['reid']);

if(!in_array($row3['topid'],$typediarr) and $row3['topid']!=0) array_push($typediarr,$row3['topid']);

require_once(DEDEDATA."/cache/inc_catalog_base.inc");

require_once(DEDEINC."/channelunit.func.php");

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

foreach($typediarr as $typeid)

{

$lv = new ListView($typeid);

$lv->MakeHtml(1,$maxpagesize);

}

}

/*火车头采集自动更新上下篇*/

function MakePreNext($aid,$typeid)

{

global $dsql;

require_once(DEDEINC.'/arc.archives.class.php');

$aid = intval($aid);

$preRow = $dsql->GetOne("SELECT id FROM `#@__arctiny` WHERE id-1 AND typeid='$typeid' ORDER BY id DESC");

$nextRow = $dsql->GetOne("SELECT id FROM `#@__arctiny` WHERE id>$aid AND arcrank>-1 AND typeid='$typeid' ORDER BY id ASC");

if(is_array($preRow))

{

$envs['aid'] = $preRow['id'];

$arc = new Archives($preRow['id']);

$arc->MakeHtml();

}

if(is_array($nextRow))

{

$envs['aid'] = $nextRow['id'];

$arc = new Archives($nextRow['id']);

$arc->MakeHtml();

}

}

继续在这个文件中找到

return $revalue;

在它的上面加入

MakePreNext($arcID,$typeid);

MakeIndex();

MakeParentType($typeid);

添加完后是这样的

这样添加好后,无论你用火车头免登录接口还是WEB发布模块,无论是普通文章模型还是图集模型还是软件模型,都可以自动生成相关静态文件了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值