Phpcms V9 to invoke the two methods of the script of the designated column sub-column

Source: Internet
Author: User
Two methods for Phpcms V9 to call the column sub-column

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

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

  • URL]} "title=" {$r [title]} "target=" _blank ">{str_cut ($r [' title '],40)} ({date (' m-d ', $r [Inputtime])})

  • {/loop}
    {/PC}

    The benefits of this approach: You can take that column to definition
    Cons: To write multiple IDs, BackstageIf you add a column, you have to write the ID again.

    the second type, 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 ( the)?? $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}
    ? ?? ???
  • [{$CATEGORYS [$r [Catid]][catname]}]{str_cut ($r [' title '],40)} [{date (' y-m-d ', $r [Inputtime])}]

  • {/loop}
    {/PC}

    Benefits: Just write a parent column ID, automaticallyTake 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.

    ?

    Http://www.veryhuo.com/a/view/30459.html

  • Related Article

    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.