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.
Things to start with:
<span style="color: #008080;"> 1</span> <ul <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav navbar-nav</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 2</span> <li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">active</span><span style="color: #800000;">"</span>><a href=<span style="color: #800000;">"</span><span style="color: #800000;">{siteurl($siteid)}</span><span style="color: #800000;">"</span>>首页</a></li> <span style="color: #008080;"> 3</span> {pc:content action=<span style="color: #800000;">"</span><span style="color: #800000;">category</span><span style="color: #800000;">"</span> catid=<span style="color: #800000;">"</span><span style="color: #800000;">0</span><span style="color: #800000;">"</span> num=<span style="color: #800000;">"</span><span style="color: #800000;">10</span><span style="color: #800000;">"</span> siteid=<span style="color: #800000;">"</span><span style="color: #800000;">$siteid</span><span style="color: #800000;">"</span> order=<span style="color: #800000;">"</span><span style="color: #800000;">listorder ASC</span><span style="color: #800000;">"</span><span style="color: #000000;">} </span><span style="color: #008080;"> 4</span> <span style="color: #000000;"> {loop $data $r} </span><span style="color: #008080;"> 5</span> {<span style="color: #0000ff;">if</span> $r[arrchildid]<span style="color: #000000;">} </span><span style="color: #008080;"> 6</span> <li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 7</span> <a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[url]}</span><span style="color: #800000;">"</span> <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown-toggle</span><span style="color: #800000;">"</span> child=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[arrchildid]}</span><span style="color: #800000;">"</span> data-toggle=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown</span><span style="color: #800000;">"</span>>{$r[catname]}<b <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">caret</span><span style="color: #800000;">"</span>></b></a> <span style="color: #008080;"> 8</span> <ul <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown-menu</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 9</span> {pc:content action=<span style="color: #800000;">"</span><span style="color: #800000;">category</span><span style="color: #800000;">"</span> catid=<span style="color: #800000;">"</span><span style="color: #800000;">$r[catid]</span><span style="color: #800000;">"</span> num=<span style="color: #800000;">"</span><span style="color: #800000;">10</span><span style="color: #800000;">"</span> siteid=<span style="color: #800000;">"</span><span style="color: #800000;">$siteid</span><span style="color: #800000;">"</span> order=<span style="color: #800000;">"</span><span style="color: #800000;">listorder ASC</span><span style="color: #800000;">"</span> <span style="color: #0000ff;">return</span>=<span style="color: #800000;">"</span><span style="color: #800000;">data2</span><span style="color: #800000;">"</span><span style="color: #000000;">} </span><span style="color: #008080;">10</span> <span style="color: #000000;"> {loop $data2 $v} </span><span style="color: #008080;">11</span> <li><a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$v[url]}</span><span style="color: #800000;">"</span>>{$v[catname]}</a></li> <span style="color: #008080;">12</span> {/<span style="color: #000000;">loop} </span><span style="color: #008080;">13</span> {/<span style="color: #000000;">pc} </span><span style="color: #008080;">14</span> </ul> <span style="color: #008080;">15</span> </li> <span style="color: #008080;">18</span> {/<span style="color: #0000ff;">if</span><span style="color: #000000;">} </span><span style="color: #008080;">19</span> {/<span style="color: #000000;">loop} </span><span style="color: #008080;">20</span> {/<span style="color: #000000;">pc} </span><span style="color: #008080;">21</span> </ul>
General idea: Query whether there is a sub-column ID under the document, and if so, output the secondary navigation. Line 5 in 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, which makes the judgment unable to achieve the expected effect, so I changed my mind and the code is as follows:
<span style="color: #008080;"> 1</span> <ul <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">nav navbar-nav</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 2</span> <li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">active</span><span style="color: #800000;">"</span>><a href=<span style="color: #800000;">"</span><span style="color: #800000;">{siteurl($siteid)}</span><span style="color: #800000;">"</span>>首页</a></li> <span style="color: #008080;"> 3</span> {pc:content action=<span style="color: #800000;">"</span><span style="color: #800000;">category</span><span style="color: #800000;">"</span> catid=<span style="color: #800000;">"</span><span style="color: #800000;">0</span><span style="color: #800000;">"</span> num=<span style="color: #800000;">"</span><span style="color: #800000;">10</span><span style="color: #800000;">"</span> siteid=<span style="color: #800000;">"</span><span style="color: #800000;">$siteid</span><span style="color: #800000;">"</span> order=<span style="color: #800000;">"</span><span style="color: #800000;">listorder ASC</span><span style="color: #800000;">"</span><span style="color: #000000;">} </span><span style="color: #008080;"> 4</span> <span style="color: #000000;"> {loop $data $r} </span><span style="color: #008080;"> 5</span> {<span style="color: #0000ff;">if</span> $r[arrchildid] !=<span style="color: #000000;"> $r[catid]} </span><span style="color: #008080;"> 6</span> <li <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 7</span> <a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[url]}</span><span style="color: #800000;">"</span> <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown-toggle</span><span style="color: #800000;">"</span> child=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[arrchildid]}</span><span style="color: #800000;">"</span> data-toggle=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown</span><span style="color: #800000;">"</span>>{$r[catname]}<b <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">caret</span><span style="color: #800000;">"</span>></b></a> <span style="color: #008080;"> 8</span> <ul <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">dropdown-menu</span><span style="color: #800000;">"</span>> <span style="color: #008080;"> 9</span> {pc:content action=<span style="color: #800000;">"</span><span style="color: #800000;">category</span><span style="color: #800000;">"</span> catid=<span style="color: #800000;">"</span><span style="color: #800000;">$r[catid]</span><span style="color: #800000;">"</span> num=<span style="color: #800000;">"</span><span style="color: #800000;">10</span><span style="color: #800000;">"</span> siteid=<span style="color: #800000;">"</span><span style="color: #800000;">$siteid</span><span style="color: #800000;">"</span> order=<span style="color: #800000;">"</span><span style="color: #800000;">listorder ASC</span><span style="color: #800000;">"</span> <span style="color: #0000ff;">return</span>=<span style="color: #800000;">"</span><span style="color: #800000;">data2</span><span style="color: #800000;">"</span><span style="color: #000000;">} </span><span style="color: #008080;">10</span> <span style="color: #000000;"> {loop $data2 $v} </span><span style="color: #008080;">11</span> <li><a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$v[url]}</span><span style="color: #800000;">"</span>>{$v[catname]}</a></li> <span style="color: #008080;">12</span> {/<span style="color: #000000;">loop} </span><span style="color: #008080;">13</span> {/<span style="color: #000000;">pc} </span><span style="color: #008080;">14</span> </ul> <span style="color: #008080;">15</span> </li> <span style="color: #008080;">16</span> {<span style="color: #0000ff;">else</span><span style="color: #000000;">} </span><span style="color: #008080;">17</span> <li><a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[url]}</span><span style="color: #800000;">"</span>>{$r[catname]}</a></li> <span style="color: #008080;">18</span> {/<span style="color: #0000ff;">if</span><span style="color: #000000;">} </span><span style="color: #008080;">19</span> {/<span style="color: #000000;">loop} </span><span style="color: #008080;">20</span> {/<span style="color: #000000;">pc} </span><span style="color: #008080;">21</span> </ul>