最新活动:电脑PC端+手机端+微网站+自适应网页多模板选择-建站388元起价!!!
要源码
当前位置:主页 > 网站建设 > dede首页调用随机文章定时自动更新,dedecms

dede首页调用随机文章定时自动更新,dedecms

时间:2023-07-22 13:07:22 阅读: 文章分类: 网站建设 作者: dede开发者

导读:dedecms

dede58模板

大家做SEO的都知道网站首页的更新频率直接决定了网站的收录速度和一部分站点权重,但dede会员中心模板是我们不能实时的去更新,在这个科技如此发达的时代如果我们还在采用最原始的办法那一定是个悲剧。没错,就像标题写的一样,自动,没错就是自动,全自动更新首页的文章列表。织梦仿站教程第一步调用随机文章:织梦仿站教程  织梦给出了随机文章调用的参数如下:{dede:arclist sort=’rand’ titlelen=48 row=16}<li><a href=&quot;[field:arcurl/]&quot; title=&quot;[field:title/]&quot; target=&quot;_blank&quot;>[field:title/]</a></li>{/dede:arclist}  这段列表代码可以调用出随机文章,并且在每次刷新动态页面的时候都会变化,但是由于织梦是首页生成静态html的,所以如果不去手动生成还是不会变化,这样就用到了下面的方法。第二步设置定时自动更新文件:  复制下面代码,粘贴到一个新文件中,命名为:autoindex.php,上传到ftp的plus文件夹中,看清楚一点是plus文件夹中,错了位置不会生效:<?phpfunction sp_input( $text ){$text = trim( $text );$text = htmlspecialchars( $text );if (!get_magic_quotes_gpc())return addslashes( $text );elsereturn $text;}$autotime = 3600;//自动更新时间,单位为秒,这里我设为一小时,大家可以自行更改。$fpath = &quot;../data/last_time.inc&quot;;//记录更新时间文件,如果不能达到目的,请检查是否有读取权限。include( $fpath );if( empty($last_time))$last_time = 0;if( sp_input($_GET[\'renew\'])==&quot;now&quot;)$last_time = 0;if((time()-$last_time)>=$autotime ){define(\'DEDEADMIN\', ereg_repdede商城模板lace(&quot;[/]{1,}&quot;,\'/\',dirname(__FILE__) ) );require_once(DEDEADMIN.&quot;/../include/common.inc.php&quot;);require_once(DEDEINC.&quot;/arc.partview.class.php&quot;);/*$row = $dsql->GetOne(&quot;Select * From dede_homepageset&quot;);$dsql->Close();$templet=$row[\'templet\'];$position=$row[\'position\'];*/$templet = “tnbjh/index.htm”;//这里是首页模板位置,当前是dede默认首面位置。$position = &quot;../index.html&quot;;$homeFildede手机模板e = dirname(__FILE__).&quot;/&quot;.$position;$homeFile = str_replace(&quot;&quot;, &quot;/&quot;, $homeFile );$homeFile = str_replace( &quot;//&quot;, &quot;/&quot;, $homeFile );$pv = new PartView();$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir.&quot;/&quot;.$templet );$pv -> SaveToHtml( $homeFile );$pv -> Close();$file = fopen( $fpath, &quot;w&quot;);fwrite( $file, &quot;<?phpn&quot;);fwrite( $file,&quot;$last_time=&quot;.time().&quot;;n&quot;);fwrite( $file, \'?>\' );fclose( $file );}?>  然后我们需要在首页的模版代码head标签中加入一段代码:<script src=&quot;/plus/autoindex.php&quot; language=&quot;javascript&quot;></script>  然后点击后台生成,更新首页。  这样就等待验证结果吧,一点要看清楚上面的注释,时间是以秒为单位的,默认3600秒是一小时,大家可以自行更改。

关键词标签: dedecms 首页 自动更新

声明: 本文由我的SEOUC技术文章主页发布于:2023-07-22 ,文章dede首页调用随机文章定时自动更新,dedecms主要讲述首页,自动更新,dedecms网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_34303.html

我的IDC 网站建设技术SEOUC.COM
专注网站建设,SEO优化,小程序设计制作搭建开发定制网站等,数千家网站定制开发案例,网站推广技术服务。
  • 5000+合作客服
  • 8年从业经验
  • 150+覆盖行业
  • 最新热门源码技术文章