Heim >php教程 >php手册 >PHPCMS V9 fügt sekundäre Navigation hinzu

PHPCMS V9 fügt sekundäre Navigation hinzu

WBOY
WBOYOriginal
2016-10-22 00:00:101123Durchsuche

Ich habe mir heute phpcms angesehen und beim Abfragen der Navigationsleisteninformationen ein Problem festgestellt. Im Dokument wurde angegeben, dass die Unterspalten-ID zurückgegeben wurde , aber es war ein bisschen anders.

Startidee:

<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>

Allgemeine Idee: Überprüfen Sie, ob unter dem Dokument eine Unterspalten-ID vorhanden ist, und geben Sie gegebenenfalls die Sekundärnavigation aus. Die fünfte Zeile im Code dient dazu, zu erkennen, ob sich unter der Spalte eine Unterspalten-ID befindet. Ich habe jedoch festgestellt, dass die ID der aktuellen Spalte zurückgegeben wird, wenn keine Unterspalte vorhanden ist, wodurch die Beurteilung nicht möglich ist der erwartete Effekt, also habe ich es mir anders überlegt und der Code lautet wie folgt:

<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>

Bestimmen Sie, ob die erhaltene Unterspalten-ID mit der Spalten-ID übereinstimmt. Wenn sie gleich ist, bedeutet dies, dass keine Unterspalte vorhanden ist und die Unterspalte vorhanden ist. Spalte wird angezeigt

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn