Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of displaying only the specified column on the home page of phpcms

Shulou Source: shulou.com Published: 2022-06-02 05:34:39 09月28日 Update

Editor to share with you the phpcms home page only shows the method of designated columns, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

How to display only specified columns on the home page of phpcms

The following code controls which columns are displayed through the column id. Id makes a background query according to the actual situation, and the subcat function explains the final attachment. The following code is modified:

{loop subcat {if $r ['catid'] = = 1 | $r [' catid'] = = 2} / / which columns are shown {php $num++} {$r} > {pc:content action= "lists" catid= "$r" order= "updatetime DESC" thumb= "1" num= "1" return= "info"} {loop $info $v}

{str_cut ($v ['title'], 28)} {str_cut ($v [' description'], 100)}

{/ loop} {/ pc} {pc:content action= "lists" catid= "$r" num= "5" order= "id DESC" return= "info"} {loop $info $v} {str_cut ($v ['title'] 40)} {/ loop} {/ pc} {if $num%2==0} {/ if} {/ if} {/ loop}

In addition to specifying specific columns, we can also use exclusion to display specific columns.

V9 method of excluding a column

{loop subcat {if $r ['catid'] = = 3} {/ if} / exclude a column {php $num++} {$r} more > {pc:content action= "lists" catid= "$r" order= "updatetime DESC" thumb= "1" num= "1" return= "info"} {loop $info $v}

{str_cut ($v ['title'], 28)} {str_cut ($v [' description'], 100)}

{/ loop} {/ pc} {pc:content action= "lists" catid= "$r" num= "5" order= "id DESC" return= "info"} {loop $info $v} {str_cut ($v ['title'] 40)} {/ loop} {/ pc} {if $num%2==0} {/ if} {/ loop}

{loop subcat (0re0re0re0remensiteid) $r} {/ loop} function explanation:

/ * * get child column * @ param $parentid parent id * @ param $type column type 1 is a single web page type, 0 is a column type (check phpcms's mysql database to see whether * @ param $self contains * @ param $siteid site id * / function subcat ($parentid = NULL,$ type = NULL,$self ='0", $siteid ='') {if (empty ($siteid)) $siteid = get_siteid (); $category = getcache ('category_content_'.$siteid,'commons') Foreach ($category as $id= > $cat) {if ($cat ['siteid'] = = $siteid & & ($parentid = NULL | | $cat [' parentid'] = = $parentid) & & ($type = NULL | | $cat ['type'] = = $type)) $subcat [$id] = $cat; if ($self = = 1 & $cat [' catid'] = = $parentid & &! $cat ['child']) $subcat [$id] = $cat;} return $subcat } above are all the contents of the phpcms home page that only shows the method of the specified column, thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Column method home page more type code content function article explanation not much background most actual situation data database way knowledge site Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information Shulou Technology OPPO Reno Huawei