PhpCms V9调用指定栏目子栏目稿子的两种方法

WBOY
Release: 2016-06-13 13:20:02
Original
842 people have browsed it

PhpCms V9调用指定栏目子栏目文章的两种方法

PhpCms V9调用指定栏目子栏目文章的两种方法

第一种、直接写子栏目id ,用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}

    这种方法的好处:可以想取那个栏目可以自定义
    缺点:要写多个id,后台增加了栏目的话得再把id写进去

    第二种,根据父栏目id,如上面的21,22,23,24,25都是 15下面的子栏目,可以这样写:

    {loop subcat(15)??$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}

    好处:只要写一个父栏目id,自动取下级子栏目id
    缺点:循环父栏目下所有的子栏目id,如果某个子栏目的内容不想显示的话,不好实现

    两种方法各有利弊,视情况选之。

    ?

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

    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!