Home > Backend Development > PHP Tutorial > PHPCMS V9 adds secondary navigation

PHPCMS V9 adds secondary navigation

高洛峰
Release: 2016-10-20 11:40:22
Original
1322 people have browsed it

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.

Starting idea:

    首页       {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}
Copy after login

General idea: Check whether there is a sub-column ID under the document, and if so, output the secondary navigation. Line 5 of 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, causing the judgment to fail to achieve the expected effect, so I changed my mind and the code is as follows:

    首页      {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}
Copy after login

Judgement acquisition Whether the sub-column id is equal to the column id, if equal, it means there is no sub-column, if not equal, it means there is a sub-column and the sub-column is displayed

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template