Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of displaying the classification name in front of the foreground article list by phpcms

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how phpcms displays category names in front of the foreground article list. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. Open phpcms\ caches\ caches_commons\ caches_data\ category_content_1.cache.php

Return array (1 = > array ('catid' = >' 1century, 'siteid' = >' 1', 'type' = >' 1', 'modelid' = >' 01', 'parentid' = >' 01', 'arrparentid' = >' 01', 'child' = >' 1Qing, 'arrchildid' = >' 1Jing 2, 3PM 5162cm, 'catname' = >' website introduction', 'style' = >', 'image' = >'' 'description' = >', 'parentdir' = >', 'catdir' = >' about', 'url' = >' / html/about/', 'items' = >' 0mm, 'hits' = >' 01', '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

As you can see, the details of all the column categories are cached here, including what we need.

'catname' = >' website introduction'

2. Open phpcms\ modules\ content\ classes\ content_tag.class.php

/ * list page label * @ 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. Add the following code after the above code

$TYPES = getcache ('category_content_1','commons'); / / get category cache 2 foreach ($return as $key= > $v) {$return [$key] [typename] = $TYPES [$v [' catid']] ['catname']; / / add a category field to the array returned by the lists tag}

4. The foreground calls the method

{$v [typename]} this is the end of phpcms's method of displaying category names in front of the foreground article list. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report