最新消息: 新版网站上线了!!!

PHPCMS v9最实用的的标签调用方法

1、调用最新文章,带所在版块;
{pc:get sql="SELECT a.title, a.catid, b.catid, b.catname, a.url as turl ,b.url as curl,a.id FROM `v9_news` a, `v9_category` b WHERE a.catid = b.catid ORDER BY `a`.`id` DESC "num="15" cache="300"}
{loop $data $r}
[{$r[catname]}] {str_cut($r['title'],26)}
{/loop}
{/pc}

2、截取调用标题长度;

{str_cut($v['title'],34)} -----超出用 ... 代替
{str_cut($v['title'],34, '???')}-----超出用 ???代替
{str_cut($v['title'],34,'')}-----超出不用任何字符代替

3、格式化时间调用;

{date('Y-m-d H:i:s',$r[inputtime])}-----2013-07-25:11:22:33
{date('m-d',$v['inputtime'])}------07-25

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

{pc:get sql="SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posidin(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}

5、显示栏目名称;

{$catname}-----只显示名称不带链接
{$CATEGORYS[$r['catid']]['catname']}-----显示栏目名称和链接

6、获取父栏目id/获取父栏目名称;

{$CATEGORY[$catid][parentid]}-----父栏目ID
{$CATEGORYS[$CAT[parentid]][catname]}-----父栏目名称

7、外部数据源调用dedecmsdb 在后台数据源处添加;

{pc:get sql="SELECT * FROM cq_member where mtype='企业' " cache="3600" dbsource="dedecmsdb"num="7" return="data"}
{loop $data $r}
{str_cut($r[uname],28,'')}
{/loop}
{/pc}

8、调用子栏目(在栏目首页模板需要用到);

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

9、显示指定id的栏目名称;

{$CATEGORYS[22]['catname']}

10、在文章面前显示文章类别;

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

11、指定变量循环增长(幻灯片经常用到);

{pc:content action="lists" catid="66" order="listorder DESC" thumb="1" num="5" }
{php $num = 0}
{loop $data $r}
linkarr[{$num}] = "{$r[url]}";picarr[{$num}] = "{$r[thumb]}";textarr[{$num}] = "{str_cut($r[title],36,'')}";
{php $num++}
{/loop}
{/pc}

12、文章调用使用limit;

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

13、文章从指定位置开始调用起始位置为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}
		
		
        

转载请注明:谷谷点程序 » PHPCMS v9最实用的的标签调用方法