V9 calls the current column line code as follows:
The code is as follows |
Copy Code |
{pc:content action= "hits" catid= "$catid" num= "a" order= "views DESC" cache= "3600"} |
Where $catid is the ID of the calling column, and if you want to implement a full station call, you need to modify the phpcmsmodulescontentclassescontent_tag.class.php file to find the following function:
The code is as follows |
Copy Code |
/** * List Label * @param $data */ Public function hits ($data) { $catid = Intval ($data [' catid ']); if (! $this->set_modelid ($catid)) return false;
$this->hits_db = Pc_base::load_model (' Hits_model '); $sql = $desc = $ids = '; $array = $ids _array = Array (); $order = $data [' Order ']; $hitsid = ' C '. $this->modelid. '-% '; $sql = "Hitsid like ' $hitsid '"; if (Isset ($data [' Day '])) { $updatetime = Sys_time-intval ($data [' Day ']) *86400; $sql. = "and updatetime> ' $updatetime '"; } if ($this->category[$catid] [' child ']) { $catids _str = $this->category[$catid] [' Arrchildid ']; $pos = Strpos ($catids _str, ', ') +1; $catids _str = substr ($catids _str, $pos); $sql. = "and catid in ($catids _str)"; } else { $sql. = "and catid= ' $catid '"; } $hits = Array (); $result = $this->hits_db->select ($sql, ' * ', $data [' limit '], $order); foreach ($result as $r) { $pos = Strpos ($r [' Hitsid '], '-', 2) + 1; $ids _array[] = $id = substr ($r [' Hitsid '], $pos); $hits [$id] = $r; } $ids = Implode (', ', $ids _array); if ($ids) { $sql = "status=99 and ID in ($ids)"; } else { $sql = '; } $this->db->table_name = $this->tablename; $result = $this->db->select ($sql, ' * ', $data [' limit '], ', ', ' id '); foreach ($ids _array as $id) { if ($result [$id] [' title ']!= ') { $array [$id] = $result [$id]; $array [$id] = Array_merge ($array [$id], $hits [$id]); } } return $array; } |
Modify the code (see note):
The code is as follows |
Copy Code |
/** * List Label * @param $data */ Public function hits ($data) { $catid = Intval ($data [' catid ']);
$this->hits_db = Pc_base::load_model (' Hits_model '); $sql = $desc = $ids = '; $array = $ids _array = Array (); $order = $data [' Order ']; $hitsid = ' C '. $this->modelid. '-% '; $sql = "Hitsid like ' $hitsid '"; if (Isset ($data [' Day '])) { $updatetime = Sys_time-intval ($data [' Day ']) *86400; $sql. = "and updatetime> ' $updatetime '"; } if (!empty ($catid) && $catid >0) {//Add judgment: ID is empty 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. = "and catid in ($catids _str)"; } else { $sql. = "and catid= ' $catid '"; } }
$hits = Array (); $result = $this->hits_db->select ($sql, ' * ', $data [' limit '], $order); foreach ($result as $r) { $pos = Strpos ($r [' Hitsid '], '-', 2) + 1; $ids _array[] = $id = substr ($r [' Hitsid '], $pos); $hits [$id] = $r; } $ids = Implode (', ', $ids _array); if ($ids) { $sql = "status=99 and ID in ($ids)"; } else { $sql = '; } $this->db->table_name = $this->tablename; $result = $this->db->select ($sql, ' * ', $data [' limit '], ', ', ' id '); foreach ($ids _array as $id) { if ($result [$id] [' title ']!= ') { $array [$id] = $result [$id]; $array [$id] = Array_merge ($array [$id], $hits [$id]); } } return $array; } |
Modify the code, regardless of the set column ID 0 or empty, can be transferred to the entire station article ranking.
Call Method 1:
The code is as follows |
Copy Code |
{pc:content action= "hits" catid= "0" num= "ten" order= "views DESC" cache= "3600"} |
Call Method 2:
code is as follows |
copy code |
{pc: content action= "hits" num= "order=" views DESC "cache=" 3600 "} |