近来看到下面这篇感觉很不错,文章主要给大家介绍了分享:织梦dede定时更新首页生成HTML的方法的相关资料,需要的朋友可以参考下
织梦给出了随即调用标签代码:
1 | {dede:arclist sort='rand' titlelen=48 row=16} | 2 | <li><a rel="nofollow noopener noreferrer" href="[field:arcurl/]" title="[field:title/]" target="_blank">[field:title/]</a></li> | |
但是随着织梦生成文件,似乎这个动态调用代码不是那么管用,为了实现随时间更新的效果,织梦人站长之家给出了详细的设置方法:复制下面代码,粘贴到一个新文件中,命名为:autoindex.php,上传到ftp的plus文件夹中,看清楚一点是plus文件夹中,错了位置不会生效:
02 | function sp_input( $text ) | 04 | $text = trim( $text ); | 05 | $text = htmlspecialchars( $text ); | 06 | if (!get_magic_quotes_gpc()) | 07 | return addslashes( $text ); | 12 | $fpath = "../data/last_time.inc"; | 14 | if( empty($last_time)) | 16 | if( sp_input($_GET['renew'])=="now") | 17 | $last_time = 0; if((time()-$last_time)>=$autotime ) | 19 | define('DEDEADMIN', ereg_replace("[/\\]{1,}",'/',dirname(__FILE__) ) ); | 20 | require_once(DEDEADMIN."/../include/common.inc.php"); | 21 | require_once(DEDEINC."/arc.partview.class.php"); | 27 | $templet = “default/index.htm”; | 28 | $position = "../index.html"; | 29 | $homeFile = dirname(__FILE__)."/".$position; | 30 | $homeFile = str_replace("\\", "/", $homeFile ); | 31 | $homeFile = str_replace( "//", "/", $homeFile ); | 33 | $pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet ); | 34 | $pv -> SaveToHtml( $homeFile ); | 36 | $file = fopen( $fpath, "w"); | 37 | fwrite( $file, "<?php\n"); | 38 | fwrite( $file,"\$last_time=".time().";\n"); | 39 | fwrite( $file, '?>' ); fclose( $file ); | |
然后我们需要在首页的模版代码head标签中加入一段代码:
1 | <script src="/plus/autoindex.php" type="text/javascript"></script> | |
然后点击后台生成,更新首页。
接下来后等待时间的验证结果
本文分享:织梦dede定时更新首页生成HTML的方法到此结束。生命的成长,需要吃饭,还需要吃苦,吃亏。小编再次感谢大家对我们的支持!