Today read Phpcms write to level two navigation when found point problem, query navigation bar information returned when the $r[arrchildid] and their imagination, the document is returned sub-column ID but a little different.
The beginning of the idea:
Home
{pc:content action= "category" catid= "0" num= "siteid=" $siteid "order=" Listorder ASC "} {Loop $data $r} {if $r [Arrchildid]} {$r [catname]} {pc:content action= "category" catid= "$r [catid]" num= "siteid=" $siteid "order=" Listorder ASC "return=" Data2 "} {Loop $data 2 $v} {$v [catname]} {/loop} {/PC} {/if} {/loop} {/PC}
General idea: Query whether there is a sub-column ID under the document, if any, output level two navigation. The 5th line in the code is to detect if there is a sub-column ID in the column, but I found that when there is no sub-column will return the current column ID resulting in the judgment can not achieve the desired effect, so change the idea, the code is as follows:
Home
{pc:content action= "category" catid= "0" num= "siteid=" $siteid "order=" Listorder ASC "} {Loop $data $r} {if $r [arrchildid]! = $r [CATID]} {$r [catname]} {pc:content action= "category" catid= "$r [catid]" num= "siteid=" $siteid "order=" Listorder ASC "return=" Data2 "} {Loop $data 2 $v} {$v [catname]} {/loop} {/PC} {Else} {$r [catname]} {/if} {/loop} {/PC}
Determines whether the obtained sub-column ID is equal to the column ID, is equal to the absence of sub-columns, does not mean that there are sub-columns and display sub-columns
The above is a small series to introduce you to the Phpcms V9 add two-level navigation of the idea of detailed, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for the support of the Scripting House website!
Related articles:
How to set the title of Phpcms V9 SEO
Phpcms V9 two times development and use of various problem solving solutions
Phpcms V9 two times how to develop custom paging functions