第一步调用随机文章: 织梦给出了随机文章调用的参数如下: {dede:arclistsort’rand’titlelen48row16} 〔field:title〕 {dede:arclist} 这段列表代码可以调用出随机文章,并且在每次刷新动态页面的时候都会变化,但是由于织梦是首页生成静态html的,所以如果不去手动生成还是不会变化,这样就用到了下面的方法。 第二步设置定时自动更新文件: 复制下面代码,粘贴到一个新文件中,命名为:autoindex。php,上传到ftp的plus文件夹中,看清楚一点是plus文件夹中,错了位置不会生效: ?php functionspinput(text) { texttrim(text); texthtmlspecialchars(text); if(!getmagicquotesgpc()) returnaddslashes(text); else } autotime3600;自动更新时间,单位为秒,这里我设为一小时,大家可以自行更改。 fpath“。。datalasttime。inc”;记录更新时间文件,如果不能达到目的,请检查是否有读取权限。 include(fpath); if(empty(lasttime)) lasttime0; if(spinput(GET〔renew〕)”now”) lasttime0; if((time()lasttime)autotime) { define(‘DEDEADMIN’,eregreplace(“〔〕{1,}”,’,dirname(FILE))); requireonce(DEDEADMIN。”。。includecommon。inc。php”); requireonce(DEDEINC。”arc。partview。class。php”); rowdsqlGetOne(“SelectFromdedehomepageset”); dsqlClose(); templetrow〔templet〕; positionrow〔position〕; templet“tnbjhindex。htm”;这里是首页模板位置,当前是dede默认首面位置。 position“。。index。html”; homeFiledirname(FILE)。””。 homeFilestrreplace(“”,“”,homeFile); homeFilestrreplace(“”,“”,homeFile); pvnewPartView(); pvSetTemplet(cfgbasedir。cfgtempletsdir。””。templet); pvSaveToHtml(homeFile); pvClose(); filefopen(fpath,“w”); fwrite(file,“?phpn”); fwrite(file,“lasttime”。time()。”;n”); fwrite(file,‘?’); fclose(file); } ? 然后我们需要在首页的模版代码head标签中加入一段代码: 然后点击后台生成,更新首页。