Two methods for Phpcms V9 to call the column sub-column

Source: Internet
Author: User


The first, directly write the sub-column ID, with Cat in


{pc:get sql= "select * from V9_news where status=99 and CatID in (21,22,23,24,25) Order by ID DESC" num= "7" return= "Data"}

{Loop $data $r}

<li><a href= "{$r [url]}" title= "{$r [title]}" target= "_blank" >{str_cut ($r [' title '],40)} ({date (' m-d ')} ({"", $r [ Inputtime]) </span></a></li>

{/loop}

{/PC}


The benefits of this approach: You can customize the column you want to take

Disadvantage: To write more than one ID, the background added to the column, the ID will be written in


The second, according to the parent column ID, such as the above 21,22,23,24,25 are 15 below the sub-column, you can write:


{loop subcat ($k) $v}

{php $subcatid [] = $k;}

{/loop}

{php $subcatid = implode (', ', $subcatid);}

{pc:get sql= "select * from V9_news where status=99 and CatID in ($subcatid) Order by ID DESC" num= "7" return= "Data"}

{Loop $data $r}

<li><span><strong><a href= "{$CATEGORYS [$r [Catid]][url]}" >[{$CATEGORYS [$r [catid]][ Catname]}]</a><a href= "{$r [url]}" title= "{$r [title]}" target= "_blank" >{str_cut ($r [' title '],40)}</a ></strong><em>[{date (' y-m-d ', $r [inputtime])}]</em></span></li>

{/loop}

{/PC}


Benefits: Just write a parent column ID, automatically take the subordinate sub-column ID

Disadvantage: The circular parent column under all the sub-column ID, if the content of a sub-column does not want to display, not good implementation


Both methods have pros and cons, depending on the circumstances of the election.


Two methods for Phpcms V9 to call the column sub-column

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.