Today, I looked at the issue that occurs when phpcms writes to the second-level navigation. The $ r [arrchildid] returned when querying the navigation bar information is inconsistent with what I imagined. in this document, the subtopic id is returned, but it is somewhat different. Today, I looked at the issue that occurs when phpcms writes to the second-level navigation. The $ r [arrchildid] returned when querying the navigation bar information is inconsistent with what I imagined. in this document, the subtopic id is returned, but it is somewhat different.
First thought:
Home page {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: query whether there is a subtopic id under this document. If yes, the second-level navigation is output. Row 5th in the code checks whether there is a subtopic id under this topic. However, I found that when there is no subtopic, the id of the current topic will be returned, leading to the failure of the judgment to achieve the expected results. so I changed my mind, the code is as follows:
Home page {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}
Determine whether the obtained subtopic id is equal to the topic id. if it is equal to or not, no subtopic is displayed. if it is not equal to or not, a subtopic is displayed.