本文介绍了织梦dedecms如何实现首页自动调用随机文章,两步就可以实现这个功能,先调用随机文章代码,然后再调用自动更新文件代码,这样就可以了。
织梦dedecms如何实现首页自动调用随机文章?下面来看看织梦调用随机文章的处理办法。
第一步调用随机文章:
织梦给出了随机文章调用的参数如下:
{dede:arclist sort=’rand’ titlelen=48 row=16}<li><a href="[field:arcurl/]" title="[field:title/]" target="_blank">[field:title/]</a></li>{/dede:arclist}
第二步设置定时自动更新文件:
复制下面代码,粘贴到一个新文件中,命名为:autoindex.php,上传到ftp的plus文件夹中:
<?php function sp_input( $text ) { $text = trim( $text ); $text = htmlspecialchars( $text ); if (!get_magic_quotes_gpc()) return addslashes( $text ); else return $text; } $autotime = 3600;//自动更新时间,单位为秒,这里我设为一小时,大家可以自行更改。 $fpath = "../data/last_time.inc";//记录更新时间文件,如果不能达到目的,请检查是否有读取权限。 include( $fpath ); if( empty($last_time)) $last_time = 0; if( sp_input($_GET['renew'])=="now") $last_time = 0; if((time()-$last_time)>=$autotime ) { define('DEDEADMIN', ereg_replace("[/\\]{1,}",'/',dirname(__FILE__) ) ); require_once
上面就是织梦调用随机文章的介绍,若有疑问可以找小编进一步探讨交流~