Detailed explanation of the idea of ​​adding secondary navigation in PHPCMS V9

PHP中文网
Release: 2023-03-03 06:14:02
Original
1179 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:

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}
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, which makes the judgment unable to achieve the expected effect, so I changed my mind and 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}
Copy after login

Determine whether the obtained sub-column id is equal to the column id. If it is equal, it means there is no sub-column. If it is not equal, it means there is a sub-column and the sub-column is displayed.

The above is the PHPCMS V9 added by the editor to add secondary navigation. Detailed explanation of the ideas, I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the Script House website!

Related articles:

How to set up SEO for the title of PHPCMS V9

Solutions to various problems in secondary development and use of phpcms v9

Methods for secondary development of custom paging functions in PHPCMS V9

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!