phpcms 调用多级栏目和多级栏目下的文章列表
实现代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
{loop subcat( $catid ) $c }
{ if $c [ 'child' ]}
{php $child = subcat( $c [ 'catid' ]);}
<div class = "wj_fenlei" >
<div class = "fenlei_pic" >
<em><img src= "{php echo $c['image'];}" width= "298" height= "144" alt= "" /></em>
<div class = "xmtit" >{php echo $c [ 'catname' ];}+</div>
<div class = "xian" >
<span>{php echo "<a href='" . $c ['url ']."' target= '_blank' >". $c [ 'catname' ]. "</a>" ;}</span>
<div class = "xm_a" >
{loop $child $catc }
{php $subcatid [] = $catc [ 'catid' ];}
{php echo "<a href='" . $catc ['url ']."' target= '_blank' >". $catc [ 'catname' ]. "</a>" ;}
{/loop}
</div>
</div>
</div>
<ul>
{php $subcatid = implode( ',' , $subcatid );}
{php $arr = explode ( ',' , $subcatid );}
{pc:get sql= "SELECT * from v9_news where status=99 and catid in ($subcatid) order by id DESC LIMIT 0,4--" num= "6" return = "data" }
{loop $data $r }
<li> <a href= "{$r[url]}" target= "_blank" title= "{$r['title']}" >● [{ $CATEGORYS [ $r [catid]][catname]}] {str_cut( $r [ 'title' ],40)}</a></li>
{/loop}
{/pc} </ul>
<div class = "zs_more" >
{php echo "<a href='" . $c ['url ']."' target= '_blank' >我想了解更多". $c [ 'catname' ]. "知识</a>" ;}
</div>
</div>
{php $subcatid = null;}
{/ if }
{/loop} |
本文转自 gutaotao1989 51CTO博客,原文链接:http://blog.51cto.com/taoyouth/1723236