phpcms最实用代码集合

1、在文章前面显示文章类别

{pc:content action="lists" catid="1" order="listorder DESC" num="10" }
{loop $data $n $r}
{if $TYPE[$r[typeid]][name]}[ {$TYPE[$r[typeid]][name]}]{/if}{str_cut($r[title],33,'')}
{/loop}
{/pc}

2、指定变量循环增长

{pc:content action="lists" catid="66" order="listorder DESC" thumb="1" num="5" }
{php $num = 0}
{loop $data $r}
<div class="{$num}">{str_cut($r[title],36,'')}</div>
{php $num++}
{/loop}
{/pc}

3、文章调用使用limit

{pc:content action="position" posid="31" order="listorder DESC"  limit='1,8--'}
{loop $data $r}
{str_cut($r[title],36,'')}
{/loop}
{/pc}

 

4、文章从指定位置开始调用起始位置为5,调用3条

{pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"}
{loop $data $r}
{str_cut($r[description],115)}...
{/loop}
{/pc}
[page]

 

5、列表页完美支持自定义字段调用 moreinfo="1"

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
[{$r['字段名']}]> {$r[title]}
{/loop}
{$pages}
{/pc}

 

6、调用子栏目

{pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorderASC"}
{loop $data $r}
{$r[catname]}
{/loop}
{/pc}

{pc:get sql="select * from v9_category where parentid=17 order by catid desc" num="5"}

 

7、多栏目调用&多推荐位调用调用需求:文章范围为59 60 61三个栏目,并且推送到了27 和28两个推荐位;从第三条开始,连续调用7篇文章。

{pc:get sql="SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posid in(27,28) and catid in(59,60,61)) order by listorder DESC" cache="3600" start="3" num="7" return="data" }
{loop $data $n $r}
{str_cut($r[title],22,'')}
{/loop}
{/pc}

 

8、

9、

10、

posted @ 2019-07-15 10:17  佰亿  阅读(347)  评论(0编辑  收藏  举报