zoukankan      html  css  js  c++  java
  • Phpcms V9 调用全站最新文章的代码

    Phpcms默认不支持调用全站最新文章,需要修改文件:\phpcms\modules\content\classes\content_tag.class.php,找到以下函数:

     1     /**
     2      * 列表页标签
     3      * @param $data
     4      */
     5     public function lists($data) {
     6         $catid = intval($data['catid']);
     7         if(!$this->set_modelid($catid)) return false;
     8         if(isset($data['where'])) {
     9             $sql = $data['where'];
    10         } else {
    11             $thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
    12             if($this->category[$catid]['child']) {
    13                 $catids_str = $this->category[$catid]['arrchildid'];
    14                 $pos = strpos($catids_str,',')+1;
    15                 $catids_str = substr($catids_str, $pos);
    16                 $sql = "status=99 AND catid IN ($catids_str)".$thumb;
    17             } else {
    18                 $sql = "status=99 AND catid='$catid'".$thumb;
    19             }
    20         }
    21         $order = $data['order'];
    22 
    23         $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
    24                         
    25         //调用副表的数据
    26         if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
    27             $ids = array();
    28             foreach ($return as $v) {
    29                 if (isset($v['id']) && !empty($v['id'])) {
    30                     $ids[] = $v['id'];
    31                 } else {
    32                     continue;
    33                 }
    34             }
    35             if (!empty($ids)) {
    36                 $this->db->table_name = $this->db->table_name.'_data';
    37                 $ids = implode('\',\'', $ids);
    38                 $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
    39                 if (!empty($r)) {
    40                     foreach ($r as $k=>$v) {
    41                         if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]);
    42                     }
    43                 }
    44             }
    45         }
    46         return $return;
    47     }

    修改为:

     1     /**
     2      * 列表页标签
     3      * @param $data
     4      */
     5     public function lists($data) {
     6         $catid = intval($data['catid']);
     7         
     8         if(isset($data['where'])) {
     9             $sql = $data['where'];
    10         } else {
    11             $thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
    12             if(!empty($catid)) {
    13                 if(!$this->set_modelid($catid)) return false;
    14                 if($this->category[$catid]['child']) {
    15                     $catids_str = $this->category[$catid]['arrchildid'];
    16                     $pos = strpos($catids_str,',')+1;
    17                     $catids_str = substr($catids_str, $pos);
    18                     $sql = "status=99 AND catid IN ($catids_str)".$thumb;
    19                 } else {
    20                     $sql = "status=99 AND catid='$catid'".$thumb;
    21                 }
    22             }
    23             else {
    24                 $sql = "status=99".$thumb;
    25             }
    26                 
    27         }
    28         $order = $data['order'];
    29 
    30         $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
    31                         
    32         //调用副表的数据
    33         if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
    34             $ids = array();
    35             foreach ($return as $v) {
    36                 if (isset($v['id']) && !empty($v['id'])) {
    37                     $ids[] = $v['id'];
    38                 } else {
    39                     continue;
    40                 }
    41             }
    42             if (!empty($ids)) {
    43                 $this->db->table_name = $this->db->table_name.'_data';
    44                 $ids = implode('\',\'', $ids);
    45                 $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
    46                 if (!empty($r)) {
    47                     foreach ($r as $k=>$v) {
    48                         if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]);
    49                     }
    50                 }
    51             }
    52         }
    53         return $return;
    54     }

    修改代码后,即能调取全站最新文章。调用方法:

    {pc:content  action="lists" num="10" order="id DESC" cache="3600"}

     

  • 相关阅读:
    [洛谷P3674]小清新人渣的本愿
    [洛谷P2698][USACO12MAR]花盆Flowerpot
    [洛谷P4329][COCI2006-2007#1] Bond
    [洛谷P3203][HNOI2010]弹飞绵羊
    [洛谷P1407][国家集训队]稳定婚姻
    [洛谷P3388]【模板】割点(割顶)
    TX2_安装view_team
    tx2的一些系统命令
    tensorflow-cnnn-mnist
    mnist数据集tensorflow实现
  • 原文地址:https://www.cnblogs.com/esion/p/2621732.html
Copyright © 2011-2022 走看看