| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |

如何調用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"& 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;然后點擊后臺生成,更新首頁,這里就可以了。
這幾篇文章你可能也喜歡:
- 清理緩存后,Dedecms尚未刷新頁面。如何解決?
- 如何將新用戶添加到DEDECMS如何設置用戶權限
- 為DEDECMS用戶分配權利的最佳實踐政策?
- DEDECM如何集成第三方統計工具(例如Youmeng)?
- DEWECMS移動適應的常見問題和解決方案?
本文由主機參考刊發,轉載請注明:如何調用DEDEDECMS主頁上的隨機文章(如何收集DEDEDECMS) http://www.k2270.com/115637.html
主機參考

















評論前必須登錄!
注冊