DedeCMS教程定時(shí)生成主頁(yè)HTML的實(shí)現(xiàn)方法_DedeCms教程
使用dedecms(織夢(mèng))更加便捷有效,今天給大家發(fā)個(gè)dedecms技巧教程。
通過(guò)教程方法可以實(shí)現(xiàn) 定時(shí)生成主頁(yè)HTML!
自動(dòng)更新主要應(yīng)用于,采集站,直接可以自動(dòng)處理。
織夢(mèng)DedeCMS自動(dòng)生成首頁(yè)html
1、需要在首頁(yè)調(diào)用隨機(jī)文章,這樣每次自動(dòng)更新才會(huì)有更新的效果,隨機(jī)文章調(diào)用標(biāo)簽如下:
通過(guò)教程方法可以實(shí)現(xiàn) 定時(shí)生成主頁(yè)HTML!
自動(dòng)更新主要應(yīng)用于,采集站,直接可以自動(dòng)處理。
織夢(mèng)DedeCMS自動(dòng)生成首頁(yè)html
1、需要在首頁(yè)調(diào)用隨機(jī)文章,這樣每次自動(dòng)更新才會(huì)有更新的效果,隨機(jī)文章調(diào)用標(biāo)簽如下:
{dede:arclist sort='rand' titlelen=48 row=16} <li><a href="[field:arcurl/]" title="[field:title/]" target="_blank">[field:title/]</a></li> {/dede:arclist} |
2、寫(xiě)一個(gè)觸發(fā)定時(shí)自動(dòng)更新的php文件:
復(fù)制下面代碼,粘貼到一個(gè)新文件中,命名為:autoindex.php,上傳到ftp的plus文件夾中,錯(cuò)了位置不會(huì)生效:
3、在首頁(yè)的模版代碼head標(biāo)簽中引入觸發(fā)文件代碼:
然后手動(dòng)更新一下首頁(yè),接下來(lái)在設(shè)置的時(shí)間過(guò)了以后如果有用戶訪問(wèn)首頁(yè)就會(huì)觸發(fā)自動(dòng)更新文件,首頁(yè)就會(huì)自動(dòng)更新一次。
復(fù)制下面代碼,粘貼到一個(gè)新文件中,命名為:autoindex.php,上傳到ftp的plus文件夾中,錯(cuò)了位置不會(huì)生效:
<?php function sp_input( $text ) { $text = trim( $text ); $text = htmlspecialchars( $text ); if (!get_magic_quotes_gpc()) return addslashes( $text ); else return $text; } $autotime = 10800;//自動(dòng)更新時(shí)間,單位為秒 $fpath = "../data/last_time.inc";//記錄更新時(shí)間文件,如果不能達(dá)到目的,請(qǐng)檢查是否有讀取權(quán)限。 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(DEDEADMIN."/../include/common.inc.php"); require_once(DEDEINC."/arc.partview.class.php"); /* $row = $dsql->GetOne("Select * From dede_homepageset"); $dsql->Close(); $templet=$row['templet']; $position=$row['position']; */ $templet = “downpk/index.htm”;//這里是首頁(yè)模板位置,當(dāng)前是dede默認(rèn)首面位置。 $position = "../index.html"; $homeFile = dirname(__FILE__)."/".$position; $homeFile = str_replace("\\", "/", $homeFile ); $homeFile = str_replace( "//", "/", $homeFile ); $pv = new PartView(); $pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet ); $pv -> SaveToHtml( $homeFile ); $pv -> Close(); $file = fopen( $fpath, "w"); fwrite( $file, "<?php\n"); fwrite( $file,"\$last_time=".time().";\n"); fwrite( $file, '?>' ); fclose( $file ); } ?> |
3、在首頁(yè)的模版代碼head標(biāo)簽中引入觸發(fā)文件代碼:
<script src="/plus/autoindex.php" type="text/javascript"></script> |
然后手動(dòng)更新一下首頁(yè),接下來(lái)在設(shè)置的時(shí)間過(guò)了以后如果有用戶訪問(wèn)首頁(yè)就會(huì)觸發(fā)自動(dòng)更新文件,首頁(yè)就會(huì)自動(dòng)更新一次。
查看更多 DedeCms教程 織夢(mèng)模板 織夢(mèng)DedeCms視頻教程 織夢(mèng)dedecms專(zhuān)題
相關(guān)DedeCms教程:
- dedecms實(shí)現(xiàn)編輯文檔自動(dòng)更新主頁(yè)和列表頁(yè)
- 秀站網(wǎng)分享:Dedecms移動(dòng)站靜態(tài)化操作方法
- 二次開(kāi)發(fā) 全站收藏總次數(shù)統(tǒng)計(jì)
- Dedecms生成百度地圖圖文教程
- 織夢(mèng)dedecms生成下拉式友情鏈接列表
- DEDECMS使用拼音首字母做欄目名稱
- 織夢(mèng)DEDECMS站群增強(qiáng)版 DedeCMS搭建站群首選
- DedeCMS Error:Tag disabled:php錯(cuò)誤的完整處理方法
- dedecms編碼轉(zhuǎn)換方法 gbk轉(zhuǎn)UTF-8,UTF-8轉(zhuǎn)GBK
- 防XSS,sql注射,代碼執(zhí)行,文件包含的通用代碼
- DedeCms教程:優(yōu)化DedeCMS搜索結(jié)果
- DedeCms教程:Linux+Apache+PHP+MySQL服務(wù)器環(huán)境(CentOS篇)
DedeCms教程教程Rss訂閱Cms教程搜索
DedeCms教程推薦
猜你也喜歡看這些
- 織夢(mèng)圖片素材下載網(wǎng)站ps設(shè)計(jì)教程網(wǎng)站
- 織夢(mèng)dede機(jī)電/機(jī)械設(shè)備公司企業(yè)網(wǎng)站模板 帶圖集數(shù)據(jù)
- 簡(jiǎn)潔快速DIV+CSS模板
- 織夢(mèng)電器維修/太陽(yáng)能電器維修模板
- 織夢(mèng)大氣燈飾產(chǎn)品展示企業(yè)通用網(wǎng)站模板
- dedecms不銹鋼金屬材料網(wǎng)站模板(中英文雙模板)
- 織夢(mèng)最新二次開(kāi)發(fā)聯(lián)動(dòng)篩選功能及風(fēng)格
- 蘑菇街 美麗說(shuō)瀑布流導(dǎo)購(gòu)DEDECMS織夢(mèng)模板
- dedecms大氣模板圖片素材收費(fèi)下載站整站模板
- 織夢(mèng)dedecms機(jī)械設(shè)備行業(yè)企業(yè)網(wǎng)站模板(綠色-寬屏-大氣)
- 相關(guān)鏈接:
復(fù)制本頁(yè)鏈接| 搜索DedeCMS教程定時(shí)生成主頁(yè)HTML的實(shí)現(xiàn)方法| DedeCms模板| Dede模板| 織夢(mèng)模板| dedecms
- 教程說(shuō)明:
DedeCms教程-DedeCMS教程定時(shí)生成主頁(yè)HTML的實(shí)現(xiàn)方法。