Jquery中文网 www.jquerycn.cn
Jquery中文网 >  建站教程  >  phpcms  >  正文 PHPCMS V9 定时发布文章是如何实现的?

PHPCMS V9 定时发布文章是如何实现的?

发布时间:2014-07-20   编辑:www.jquerycn.cn
为大家介绍PHPCMS V9中是如何实现文章的定时发布,有需要的朋友,可以看看。

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,执行第一步添加的通过审核代码。

简单二步,轻松实现phpcms v9中文章的定时发布,学习编程是多么快乐的一件事呢?呵呵!!

您可能感兴趣的文章:
PHPCMS V9 定时发布文章是如何实现的?
PHPCMS V9源码-网站入口文件index.php
phpcms用什么开发的
如何让PHPCMS V9首页无法只显示推荐的友情链接
phpcms v9更换域名后上传图片功能无效的解决办法
PHPCMS V9 调用随机文章的方法
PHPCMS v9后台登陆提示验证码错误的解决方法
phpcms用了什么框架?
Phpcms V9内容编辑器设置支持JavaScript
PHPCMS v9 如何在手机端栏目绑定模板

[关闭]