织梦CMS首页调用随机文章实现自动更新

分类:模板变量教程 发布时间:2019-05-15 20:18:26

摘要:织梦CMS首页如何&怎么调用随机文章实现自动更新?Dede首页调用随机文章实现自动更新教程&方法,适用于织梦5.7

一、调用随机文章:

织梦给出了随机文章调用的参数如下:

  1. {dede:arclist sort=’rand’ titlelen=48 row=16}
  2. <li><a href="[field:arcurl/]" title="[field:title/]" target="_blank">[field:title/]</a></li>
  3. {/dede:arclist}

二、设置定时自动更新文件:

复制下面代码,粘贴到一个新文件中,命名为:autoindex.php,上传到ftp的plus文件夹中:

  1. <?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