Phpcms V9 调用全站最新文章的代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-19 22:28:23 浏览: 评论:0
Phpcms默认不支持调用全站最新文章,需要修改文件\phpcms\modules\content\classes\content_tag.class.php,找到以下函数:
- public function lists($data) {
- $catid = intval($data['catid']);
- if(!$this->set_modelid($catid)) return false;
- if(isset($data['where'])) {
- $sql = $data['where'];
- } else {
- $thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
- if($this->category[$catid]['child']) {
- $catids_str = $this->category[$catid]['arrchildid'];
- $pos = strpos($catids_str,',')+1;
- $catids_str = substr($catids_str, $pos);
- $sql = "status=99 AND catid IN ($catids_str)".$thumb;
- } else {
- $sql = "status=99 AND catid='$catid'".$thumb;
- }
- }
- $order = $data['order'];
- $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
- //调用副表的数据
- if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
- $ids = array();
- foreach ($return as $v) {
- if (isset($v['id']) && !emptyempty($v['id'])) {
- $ids[] = $v['id'];
- } else {
- continue;
- }
- }
- if (!emptyempty($ids)) {
- $this->db->table_name = $this->db->table_name.'_data';
- $ids = implode('\',\'', $ids);
- $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
- if (!emptyempty($r)) {
- foreach ($r as $k=>$v) {
- if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]);
- }
- }
- }
- }
- return $return;
- }
- //修改为:
- public function lists($data) {
- $catid = intval($data['catid']);
- if(isset($data['where'])) {
- $sql = $data['where'];
- } else {
- $thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
- if(!emptyempty($catid)) {
- if(!$this->set_modelid($catid)) return false;
- if($this->category[$catid]['child']) {
- $catids_str = $this->category[$catid]['arrchildid'];
- $pos = strpos($catids_str,',')+1;
- $catids_str = substr($catids_str, $pos);
- $sql = "status=99 AND catid IN ($catids_str)".$thumb;
- } else {
- $sql = "status=99 AND catid='$catid'".$thumb;
- }
- }
- else {
- $sql = "status=99".$thumb;
- } //phpfensi.com
- }
- $order = $data['order'];
- $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
- //调用副表的数据
- if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
- $ids = array();
- foreach ($return as $v) {
- if (isset($v['id']) && !emptyempty($v['id'])) {
- $ids[] = $v['id'];
- } else {
- continue;
- }
- }
- if (!emptyempty($ids)) {
- $this->db->table_name = $this->db->table_name.'_data';
- $ids = implode('\',\'', $ids);
- $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
- if (!emptyempty($r)) {
- foreach ($r as $k=>$v) {
- if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]);
- }
- }
- }
- }
- return $return;
- }
修改代码后,即能调取全站最新文章.
调用方法:{pc:content action="lists" num="10" order="id DESC" cache="3600"}
Tags: Phpcms最新文章 Phpcms全站最新
相关文章
- ·PHPCMS中最新文章标题后显示NEW或时间为红色的修改方法(2014-10-18)
- ·phpcms v9怎么调用网站最新文章(2014-10-19)
- ·phpcms v9调用全站最新文章功能代码(2014-10-20)
- ·phpcms v9全站最新文章调用几个方法(2014-11-27)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)