新闻中心

PHPCMS定时发布文章的方法

作者 / 无忧主机 时间 2014-08-31 10:29:55

Wordpress中,添加博文的时候,发布日期写未来的时间,那么在时间到来的时候,文章会自动发布出现在首页,做到预约发布、自动发布。详情请见《深入浅出图片剖析WORDPRESS设置定时发布文章功能》其实在 Phpcms V9中同样可以做到定时发布,这样就可以预先设置些文章,在假期可以定时发布,避免出现类似出去旅游期间,更新文章停了1个月的时间。 具体怎么做到Phpcms V9文章定时发布呢?这一方法来自PC论坛,具体方法如下。 1、修改api/count.php这一文件,在PHP语句结束代码 ?>前,加入以下代码: //add 定时发布审核功能 $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) ){ //执行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 ); } 这样,我们借统计代码在更新的时候,让需要审核的文章在预定的时间点通过发布。 2、在文章页面的模板里边添加统计代码: <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script> 默认的模板里边已经默认添加了这句统计代码,检查下,这样文章在被浏览的时候,触发这个JS,就会执行第一步添加的通过审核代码。 具体上面的两个步骤,大家可以尝试下!同时欢迎各位站长朋友加QQ340555012多研究、多尝试。 希望可以帮助到各位站长朋友!   无忧主机相关文章推荐阅读: PHPCMS添加友情链接图文教程 PHPCMS出现网站文字标题颜色样式修改无效BUG PHPCMS数据库配置文件CONFIG.INC.PHP详细说明 PHPCMSV9上传图片或者附件失败出现UNDEFINED四种解决方法总结

本文地址:https://www.51php.com/phpcms/16012.html

1
1
1
1
1
1
1

客户服务热线

0791-8623-3537

在线客服