PHPCMS V9, phpcmsv9
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:
<Ul class = "nav navbar-nav"> <li class = "active"> <a href = "{siteurl ($ siteid )} "> homepage </a> </li> {pc: content action = "category" catid = "0" num = "10" siteid = "$ siteid" order = "listorder ASC"} {loop $ data $ r} {if $ r [arrchildid]} <li class = "dropdown"> <a href = "{$ r [url]}" class = "dropdown-toggle" child = "{$ r [arrchildid ]} "data-toggle =" dropdown ">{$ r [catname]} <B class =" caret "> </B> </a> <ul class =" dropdown -menu "> {pc: content action = "category" catid = "$ r [catid]" num = "10" siteid = "$ siteid" order = "listorder ASC" return = "data2"} {loop $ data2 $ v} <li> <a href = "{$ v [url]}" >{$ v [catname] }</a> </li> {/loop} {/pc} </ul> </li> {/if} {/loop} {/pc} </ul>
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:
<Ul class = "nav navbar-nav"> <li class = "active"> <a href = "{siteurl ($ siteid )} "> homepage </a> </li> {pc: content action = "category" catid = "0" num = "10" siteid = "$ siteid" order = "listorder ASC"} {loop $ data $ r} {if $ r [arrchildid]! = $ R [catid]} <li class = "dropdown"> <a href = "{$ r [url]}" class = "dropdown-toggle" child = "{$ r [arrchildid]} "data-toggle =" dropdown ">{$ r [catname]} <B class =" caret "> </B> </a> <ul class = "dropdown-menu"> {pc: content action = "category" catid = "$ r [catid]" num = "10" siteid = "$ siteid" order = "listorder ASC" return = "data2"} {loop $ data2 $ v} <li> <a href = "{$ v [url]}" >{$ v [catname] }</a> </li> {/loop} {/pc} </ul> </li> {else} <li> <a href = "{$ r [url]}" >{$ r [catname]} </a> </li> {/if} {/loop} {/pc} </ul>
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.
The above is a detailed explanation of how to add secondary navigation to PHPCMS V9. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!