Phpcms V9 Add level Two navigation ideas detailed _php example

Source: Internet
Author: User

Today I looked at the phpcms write to level two navigation found a problem, query the navigation bar information returned $r[arrchildid] and their own imagination, the document said to return the sub-column ID but a little different.

The beginning of the idea:

<ul class= "Nav navbar-nav" >
<li class= "active" ><a href= "{SiteURL ($siteid)}" > Home </a>< /li>
{pc:content action= "category" catid= "0" num= "ten" 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= "" siteid= "$siteid" order= " Listorder ASC "return=" Data2 "}
{loop $data 2 $v}
<li><a href= ' {$v [url]} ' >{$v [catname]}</a ></li>
{/loop}
{/pc}
</ul> 
</li>
{/if} {
/loop} {
/PC}
</ul>

General idea: Query the document whether there is a child column ID, if there is output level two navigation. The 5th line in the code is to detect whether there is a sub column ID, but I found that when there is no sub-column will return the ID of the current column causes the judgment can not achieve the desired effect, so change the idea, the code is as follows:

<ul class= "Nav navbar-nav" >
<li class= "active" ><a href= "{SiteURL ($siteid)}" > Home </a>< /li>
{pc:content action= "category" catid= "0" num= "ten" 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 $data 2 $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>

To determine whether to get the child column ID equal to the column ID, equal to means that there is no sub column, does not mean that there is a child column and display sub columns

The above is a small set to introduce the PHPCMS V9 add two level of navigation ideas to explain, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.