全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2419|回复: 3

PHPCMS V9 定时发布文章的实现方法

[复制链接]
发表于 2016-10-2 16:06:51 | 显示全部楼层 |阅读模式
在这里,CMSYOU与大家分享怎么让Phpcms V9自动发布文章,所谓Phpcms V9文章定时发布。
  在Wordpress中,添加博文的时候,发布日期写未来的时间,那么在时间到来的时候,文章会自动发布出现在首页,做到预约发布、自动发布。其实在Phpcms V9中同样可以做到定时发布,这样就可以预先设置些文章,在假期可以定时发布,避免出现类似CMSYOU在过年期间,更新文章停了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,就会执行第一步添加的通过审核代码。
  具体上面的两个步骤,大家可以尝试下!同时欢迎朋友多研究、多尝试。
TAGS: Phpcms,定时发布文章
本文链接:http://www.cy32.com/CMS/PHPCMS/2016-01-26/cy32-24392.html
换友情链接

www.u5g.net        U5G小说网
www.7647.org        华文小说网
www.8n1.cn        八牛绿色软件下载站
www.cy32.com    彩云之家|网络编程社区
发表于 2016-10-2 21:20:51 | 显示全部楼层
兄弟你发错区了,这个是 干货区,但是是关于买买买的
发表于 2016-10-7 18:36:27 | 显示全部楼层
唔,帖子别乱内嵌广告。。。

这种帖子发多了会有奇迹出现。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-25 22:23 , Processed in 0.062513 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表