phpcms如何在前臺文章列表前顯示分類名稱

phpcms如何在前臺文章列表前顯示分類名稱

1、打開phpcmscachescaches_commonscaches_datacategory_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'?=>?'網(wǎng)站介紹', ????'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

可以看到,這里緩存了所有欄目類別的詳細(xì)信息,其中就有我們需要的

‘catname’ => ‘網(wǎng)站介紹’,

2、打開phpcmsmodulescontentclassescontent_tag.class.php

/** ?????*?列表頁標(biāo)簽 ?????*?@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、在上述代碼后加入以下代碼

立即學(xué)習(xí)PHP免費學(xué)習(xí)筆記(深入)”;

$TYPES?=?getcache('category_content_1','commons');//獲取類別緩存2????????? ????foreach?($return?as?$key=>$v)?{??????????????????????????????????????? $return[$key][typename]=$TYPES[$v['catid']]['catname'];//給lists標(biāo)簽返回的數(shù)組中增加一個類別字段 }

4、前臺調(diào)用方法

{$v[typename]}

相關(guān)文章教程推薦:phpcms教程

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊5 分享