找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 98|回复: 0

[cms教程] Phpcms V9 调用全站最新文章的代码

[复制链接]

该用户从未签到

发表于 2019-3-24 15:53:00 | 显示全部楼层 |阅读模式

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Phpcms V9 调用全站最新文章的代码
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;      } [/ol,修改为:/**       * 列表页标签       * @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;      } [/ol,修改代码后,即能调取全站最新文章。
调用方法:{pc:content action="lists" num="10" order="id DESC" cache="3600"}
回复

使用道具 举报

网站地图|页面地图|文字地图|Archiver|手机版|小黑屋|找资源 |网站地图

GMT+8, 2024-10-5 11:32

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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