phpcms v9實現(xiàn)內(nèi)容定時發(fā)布功能二次開發(fā)教程

字號:


    phpcms v9實現(xiàn)內(nèi)容定時發(fā)布功能二次開發(fā)教程,cms教程注意本功能不適用于生成靜態(tài)的網(wǎng)站。
    首先把欄目的工作流設(shè)置成“一級審核”
    然后,在phpcms/modules/content/ 文件夾里新建一個文件命名:my_index.php
    內(nèi)容如下:
    本帖隱藏的內(nèi)容需要回復才可以瀏覽
    defined('in_phpcms') or exit('no permission resources.');
    //模型緩存路徑
    class my_index extends index {
    private $db;
    function __construct() {
    $this->db = pc_base::load_model('content_model');
    parent::__construct();
    $this->dingshi();
    }
    //定時發(fā)布
    public function dingshi() {
    $this->content_check_db = pc_base::load_model('content_check_model');
    $ids = $this->content_check_db->select('status=1 and username=phpcms8 and inputtime<='.sys_time,'checkid');
    foreach($ids as $k)
    {
    $k1 = explode('-',$k['checkid']);
    $this->db->set_model($k1[2]);
    $this->db->status($k1[1]);
    }
    }
    }
    ?>
    這樣,當有用戶通過動態(tài)地址訪問你的content??鞎r,如果定時到了,文章就會自動審核發(fā)布。
    注意:
    1、生成靜態(tài)的網(wǎng)站要用的話,可以把網(wǎng)站默認文檔設(shè)置成index.php優(yōu)先于index.html,這樣當訪問首頁時也有效果。
    2、設(shè)置欄目為“一級審核”,發(fā)布定時文章時,除了選擇發(fā)布時間外,還要把狀態(tài)設(shè)置為“審核”。
    3、定時發(fā)布的文章很多時建議使用“fsockopen”偽異步處理,否則出發(fā)定時發(fā)布的會員會很卡。
    4、修改username=phpcms8中的phpcms8為你的管理員用戶名。
    ok,phpcms v9內(nèi)容定時發(fā)布功能實現(xiàn)。