phpcms如何调用子栏目栏目说明

2024-11-12 08:51:31
推荐回答(2个)
回答1:

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}

  • {str_cut($r['title'],40)}({date('m-d',$r[inputtime])})

  • {/loop}
    {/pc}
    第二种,根据父栏目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}

    回答2:

    因为$catid是当前栏目id,调用出来的当然是当前栏目的内容,你把$catid那个位置换成子栏目id不就行了,{pc:content action="category" catid="$catid"} 获取一下当前栏目子栏目id