最近做单位网站模版遇到的问题,欲实现的效果:

 phpcms如何在前台文章列表前显示所属类别名称

但是phpcms中自带的文章列表标签没有这个功能,数据库中文章表中也只有类别id的字段,因此不能通过简单的{$r[catname]}读出来类别名。

从网上查询找到的解决方案是这样的【phpcms-v9】利用[后台]->[类别管理]为文章前后台添加类别名称,其中比较实用的方案是直接从缓存中读取类别信息,但这个方案适用的phpcms版本较老了,用了没效果,经过查看分析源码,找到解决方案如下(适用于phpcms_v9.5.9版本):

1、打开phpcms\caches\caches_commons\caches_data\category_content_1.cache.php

 1 return array (
 2   1 => 
 3   array (
 4     'catid' => '1',
 5     'siteid' => '1',
 6     'type' => '1',
 7     'modelid' => '0',
 8     'parentid' => '0',
 9     'arrparentid' => '0',
10     'child' => '1',
11     'arrchildid' => '1,2,3,5,162',
12     'catname' => '网站介绍',
13     'style' => '',
14     'image' => '',
15     'description' => '',
16     'parentdir' => '',
17     'catdir' => 'about',
18     'url' => '/html/about/',
19     'items' => '0',
20     'hits' => '0',
21     'setting' => 'array (
22   \'ishtml\' => \'1\',
23   \'template_list\' => \'default\',
24   \'page_template\' => \'page\',
25   \'meta_title\' => \'\',
26   \'meta_keywords\' => \'\',
27   \'meta_description\' => \'\',
28   \'category_ruleid\' => \'1\',
29   \'show_ruleid\' => \'\',
30   \'repeatchargedays\' => \'1\',
31 )',
category_content_1.cache.php

相关文章: