### [phpcms如何在前台文章列表前显示分类名称](https://www.prosaas.cn/article/7053) **Published:** 2020-02-06T06:56:04 **Author:** 5201314 **Excerpt:** 1、打开phpcms\caches\caches_commons\caches_data\category_c… ![](//zhiqipro.oss-cn-beijing.aliyuncs.com/2023/12/20231212125656362.jpg) 1、打开phpcms\\caches\\caches\_commons\\caches\_data\\category\_content\_1.cache.php return array ( 1 => array ( 'catid' => '1', 'siteid' => '1', 'type' => '1', 'modelid' => '0', 'parentid' => '0', 'arrparentid' => '0', 'child' => '1', 'arrchildid' => '1,2,3,5,162', 'catname' => '网站介绍', 'style' => '', 'image' => '', 'description' => '', 'parentdir' => '', 'catdir' => 'about', 'url' => '/html/about/', 'items' => '0', 'hits' => '0', 'setting' => 'array ( \\'ishtml\\' => \\'1\\', \\'template\_list\\' => \\'default\\', \\'page\_template\\' => \\'page\\', \\'meta\_title\\' => \\'\\', \\'meta\_keywords\\' => \\'\\', \\'meta\_description\\' => \\'\\', \\'category\_ruleid\\' => \\'1\\', \\'show\_ruleid\\' => \\'\\', \\'repeatchargedays\\' => \\'1\\', )', category\_content\_1.cache.php 可以看到,这里缓存了所有栏目类别的详细信息,其中就有我们需要的 'catname' => '网站介绍', 2、打开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'); content\_tag.class.php 3、在上述代码后加入以下代码 $TYPES = getcache('category\_content\_1','commons');//获取类别缓存2 foreach ($return as $key=>$v) { $return\[$key\]\[typename\]=$TYPES\[$v\['catid'\]\]\['catname'\];//给lists标签返回的数组中增加一个类别字段 } 4、前台调用方法 {$v\[typename\]} 相关文章教程推荐:phpcms教程 以上就是phpcms如何在前台文章列表前显示分类名称的详细内容,更多请关注知企PROSAAS其它相关文章! **Tags:** class, php, PHPCMS **Categories:** PHPCMS ---