This article mainly introduces some problems encountered when adding secondary navigation in PHPCMSV9. $ r [arrchildid] returned when querying the navigation bar information is inconsistent with what you think, in this document, the subtopic IDs are returned, but they are somewhat different. The following is a small Editor. I will share this article with you to answer the question that I found when I checked my phpcms and wrote it to the secondary navigation. The $ r [arrchildid] returned when I queried the information in the navigation bar is inconsistent with what I imagined, in this document, the subtopic IDs are returned, but they are somewhat different.
First thought:
Homepage
{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:
Homepage
{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.
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. I would like to thank you for your support for the script home website!
Related articles:
How to set SEO for the title of PHPCMS V9
Phpcms v9 secondary development and use of various problem solutions
PHPCMS V9 secondary development of custom paging functions