新聞中心
PHPCMS定時(shí)發(fā)布文章的方法
在Wordpress中,添加博文的時(shí)候,發(fā)布日期寫未來的時(shí)間,那么在時(shí)間到來的時(shí)候,文章會(huì)自動(dòng)發(fā)布出現(xiàn)在首頁,做到預(yù)約發(fā)布、自動(dòng)發(fā)布。詳情請(qǐng)見《深入淺出圖片剖析WORDPRESS設(shè)置定時(shí)發(fā)布文章功能》其實(shí)在 Phpcms V9中同樣可以做到定時(shí)發(fā)布,這樣就可以預(yù)先設(shè)置些文章,在假期可以定時(shí)發(fā)布,避免出現(xiàn)類似出去旅游期間,更新文章停了1個(gè)月的時(shí)間。 具體怎么做到Phpcms V9文章定時(shí)發(fā)布呢?這一方法來自PC論壇,具體方法如下。 1、修改api/count.php這一文件,在PHP語句結(jié)束代碼 ?>前,加入以下代碼: //add 定時(shí)發(fā)布審核功能 $urlobj = pc_base::load_app_class('url', 'content'); $html = pc_base::load_app_class('html', 'content'); $modelid = $modelid ? $modelid : intval($_GET['modelid']); $content_db = $content_db ? $content_db : pc_base::load_model('content_model'); $content_db->set_model($modelid); $where = ' status = 1 and inputtime <= '.SYS_TIME; $r = $content_db->count($where); if( !empty($r) ){ //執(zhí)行update操作 $ids = $content_db->select($where, 'id,catid', $r, '', '', 'id'); foreach($ids AS $kid=>$v){ $catid = $v['catid']; $id = $kid; $r = $content_db->get_content($catid,$id); $urls = $urlobj->show($id, 0, $catid, $r['inputtime'], $r['prefix'],$r,'add'); if($urls['content_ishtml']) $html->show($urls[1],$urls['data'],0); $html->index(); $html->create_relation_html($catid); } $content_db->update( array('status'=>99),$where ); } 這樣,我們借統(tǒng)計(jì)代碼在更新的時(shí)候,讓需要審核的文章在預(yù)定的時(shí)間點(diǎn)通過發(fā)布。 2、在文章頁面的模板里邊添加統(tǒng)計(jì)代碼: <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script> 默認(rèn)的模板里邊已經(jīng)默認(rèn)添加了這句統(tǒng)計(jì)代碼,檢查下,這樣文章在被瀏覽的時(shí)候,觸發(fā)這個(gè)JS,就會(huì)執(zhí)行第一步添加的通過審核代碼。 具體上面的兩個(gè)步驟,大家可以嘗試下!同時(shí)歡迎各位站長(zhǎng)朋友加QQ340555012多研究、多嘗試。 希望可以幫助到各位站長(zhǎng)朋友! 無憂主機(jī)相關(guān)文章推薦閱讀: PHPCMS添加友情鏈接圖文教程 PHPCMS出現(xiàn)網(wǎng)站文字標(biāo)題顏色樣式修改無效BUG PHPCMS數(shù)據(jù)庫配置文件CONFIG.INC.PHP詳細(xì)說明 PHPCMSV9上傳圖片或者附件失敗出現(xiàn)UNDEFINED四種解決方法總結(jié)
本文地址:http://m.love62.cn/phpcms/16012.html
![1](/wp-content/themes/starow_z/img/o-1.png)
![1](/wp-content/themes/starow_z/img/o-2.png)
![1](/wp-content/themes/starow_z/img/o-3.png)
![1](/wp-content/themes/starow_z/img/o-4.png)
![1](/wp-content/themes/starow_z/img/o-5.png)
![1](/wp-content/themes/starow_z/img/o-6.png)
![1](/wp-content/themes/starow_z/img/o-7.png)