VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云最新优惠促销活动
jtti最新优惠促销活动

如何调用DEDEDECMS主页上的随机文章(如何收集DEDEDECMS)

locvps
主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

如何调用DEDEDECMS主页上的随机文章(如何收集DEDEDECMS)

如何调用dedecms主页上的随机文章?

本文以实例描述了dedecms主页调用随机文章和自动更新功能的实现方法。分享给大家供大家参考。具体实施方法如下:

推荐学习:梦想编织cms

我们知道Dreamweaver在大多数情况下会生成静态html文件,这可以减轻服务器的负载,并从另一方面进行优化。然而,Dreamweaver本身是静态的,需要手动更新,而不是自动更新。今天,我们将谈论如何实现自动更新。

①调用随机文章:

Dreaming给出了随机物品调用的参数如下:

代码如下:

{ dede:arclist sort = & amp;#39;兰德公司。#39;titlelen = 48 row = 16 } & lt李& gt& lta href = & quot【字段:arcurl/】& quot;title = & quot【field:title/】& quot;target = & quot_blank&quot& gt【field:title/】& lt;/a & gt;& lt/李& gt{/dede:arclist }(2)计划时自动更新文件:

复制以下代码,将其粘贴到一个新文件中,将其命名为autoindex.php,并上传到ftp的plus文件夹中。看清楚是在plus文件夹中,错误的位置不会生效。

代码如下:

& lt?php函数sp _ input($ text){ $ text = trim($ text);$ text = htmlspecialchars($ text);如果(!get_magic_quotes_gpc())返回add slashes($ text);else返回$ text} $ autotime = 3600//以秒为单位自动更新时间。我在这里设置为一小时,所以你可以自己更改。$ fpath = & quot../data/last _ time . Inc & quot;;//记录更新时间文件。如果无法达到目的,请检查您是否有读取权限。包括($ fpath);if(empty empty($ last _ time)($ last _ time)= 0;if(sp _ input($ _ GET【& amp;#39;续签& amp#39;】)= = = & quot;现在& quot)$ last _ time = 0;if((time()-$ last _ time)& gt;= $ autotime){ define(& amp;#39;迪德明& amp#39;,ereg _ replace(& quot;【/\ \】{ 1,} & quot,& amp#39;/& amp;#39;,dirname(_ _ FILE _ _)));require _ once(dede admin。"/../include/common . Inc . PHP & quot;);require _ once(dede Inc。"/arc . part view . class . PHP & quot;);$ templet = & quottnbjh/index . htm & quot;;//这是主页模板位置,当前是dede的默认主页位置。$ position = & quot../index . html & quot;;$ homeFile = dirname(_ _ FILE _ _)。"/& quot;。$ position$ homeFile = str _ replace(& quot;\ \ & quot,& quot/& quot;,$ homeFile);$ homeFile = str _ replace(& quot;//& quot;,& quot/& quot;,$ homeFile);$ PV = new part view();$ PV-& gt;SetTemplet (cfg _ basedir。$cfg_templets_dir。"/& quot;。$ templet);$ PV-& gt;SaveToHtml($ homeFile);$ PV-& gt;close();$ file = fopen($ fpath,& quotw & quot);fwrite(file,& quot& lt?php \ n & quot);fwrite(file,& quot\ $ last _ time = & quot。时间()。";\ n & quot);fwrite($ file;#39;?& gt& amp#39;);fclose($ file);} ?& gt然后我们需要在主页的模板代码头标签中添加一个代码:

代码如下:

& lt脚本src = & quot/plus/auto index . PHP & quot;language = & quotjavascript & quot& gt& lt/script & gt;然后点击后台生成,更新首页,这里就可以了。

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:如何调用DEDEDECMS主页上的随机文章(如何收集DEDEDECMS) https://zhujicankao.com/115637.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 如何调用DEDEDECMS主页上的随机文章(如何收集DEDEDECMS)
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!