I looked at phpcms today and found a problem when writing the secondary navigation. When querying the navigation bar information, the $r[arrchildid] returned was not consistent with what I imagined. The document said that the sub-column id was returned, but it was somewhat different.
Starting idea:
首页 {pc:content action="category" catid="0" num="10" siteid="$siteid" order="listorder ASC"} {loop $data $r} {if $r[arrchildid]} {$r[catname]} {pc:content action="category" catid="$r[catid]" num="10" siteid="$siteid" order="listorder ASC" return="data2"} {loop $data2 $v} {$v[catname]} {/loop} {/pc} {/if} {/loop} {/pc}
General idea: Check whether there is a sub-column ID under the document, and if so, output the secondary navigation. Line 5 of the code is to detect whether there is a sub-column ID under the column, but I found that when there is no sub-column, the ID of the current column will be returned, causing the judgment to fail to achieve the expected effect, so I changed my mind and the code is as follows:
首页 {pc:content action="category" catid="0" num="10" siteid="$siteid" order="listorder ASC"} {loop $data $r} {if $r[arrchildid] != $r[catid]} {$r[catname]} {pc:content action="category" catid="$r[catid]" num="10" siteid="$siteid" order="listorder ASC" return="data2"} {loop $data2 $v} {$v[catname]} {/loop} {/pc} {else} {$r[catname]} {/if} {/loop} {/pc}
Judgement acquisition Whether the sub-column id is equal to the column id, if equal, it means there is no sub-column, if not equal, it means there is a sub-column and the sub-column is displayed