发表日期:2019-12 文章编辑:小灯 浏览次数:4217
Phpcms默认不支持调用全站最新文章,需要修改文件:\phpcms\modules\content\classes\content_tag.class.php,找到以下函数:
修改为:
- /**
- * 列表页标签
- * @param $data
- */
- 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;
- }
修改代码后,即能调取全站最新文章。
- /**
- * 列表页标签
- * @param $data
- */
- 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;
- }
- }
- $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;
- }
日期:2019-12 浏览次数:4667
日期:2019-12 浏览次数:4108
日期:2019-12 浏览次数:3847
日期:2019-12 浏览次数:4095
日期:2019-12 浏览次数:4216
日期:2019-12 浏览次数:3999
日期:2019-12 浏览次数:4265
日期:2019-12 浏览次数:3919
日期:2019-12 浏览次数:4434
日期:2019-12 浏览次数:4456
日期:2019-12 浏览次数:4201
日期:2019-12 浏览次数:4778
日期:2019-12 浏览次数:4163
日期:2019-12 浏览次数:3995
日期:2019-12 浏览次数:4052
日期:2019-12 浏览次数:3968
日期:2019-12 浏览次数:4239
日期:2019-12 浏览次数:4062
日期:2019-12 浏览次数:4061
日期:2019-12 浏览次数:5444
日期:2019-12 浏览次数:4533
日期:2019-12 浏览次数:3902
日期:2019-12 浏览次数:3951
日期:2019-12 浏览次数:4021
日期:2019-12 浏览次数:4745
日期:2019-12 浏览次数:3899
日期:2019-12 浏览次数:3821
日期:2019-12 浏览次数:4144
日期:2019-12 浏览次数:3766
日期:2019-12 浏览次数:4053
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.