到目前为止用到过的phpcms语法:

1、取栏目名称:

{$CATEGORYS[$catid][catname]}
{$CATEGORYS[$top_parentid][catname]}

2、取栏目地址:

{$CATEGORYS[$catid][url]}

  

3、取一级栏目:

{pc:content action="category" catid="0" num="5" siteid="$siteid" order="listorder ASC"}
{loop $data $r} {/loop}
{/pc}

  

4、取带二级栏目的导航:

{pc:content action="category" catid="0" num="5" siteid="$siteid" order="listorder ASC"}
{loop $data $r} {pc:content action="category" catid="$r[catid]" num="3" siteid="$siteid" order="listorder ASC"}
{loop $data $v} {/loop}
{/pc} {/loop}
{/pc}

  

加判断:

{pc:content action="category" catid="0" num="4" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<!--$catid==$r[catid]表示判断该栏目id是否等于栏目id-->
<!--$top_parentid==$r[catid]表示如果是二级栏目的情况下,判断顶级栏目是否等于栏目id-->
{if $catid==$r[catid]||$top_parentid==$r[catid]}
<a href="{$r[url]}"><div class="menu menu_sel">{$r[catname]}</div></a>
{else}
<a href="{$r[url]}"><div class="menu">{$r[catname]}</div></a>
{/if}
{/loop}
{/pc}

  

5、取内容:

{pc:content action="lists" catid="60" order="listorder ASC" num="3" moreinfo="1" page="$page"}
{loop $data $key $val} $val[title] {/loop}
{/pc}

  

灵活运用:

{pc:content action="lists" catid="60" order="listorder ASC" num="3"}
{loop $data $key $val}
{if $key=="106"}
// {if $key=="$id"} $id是当前传过来id
<div class="aa" style="width:880px;"><a href="{$val[url]}"> {$val[title]}</a></div>
{else}
<div class="aa" style="width:880px ; display: none;"><a href="{$val[url]}"> {$val[title]}</a></div>
{/if}
{/loop}
{/pc}

  

{pc:content action="category" catid="$top_parentid" num="4" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
{if $r[catid]=="38"}
<li class="c-li li-sel"><a href="{$r[url]}">{$r[catname]}</a></li>
{else}
<li class="c-li"><a href="{$r[url]}">{$r[catname]}</a></li>
{/if}
{/loop}
{/pc}

  

6、判断是否为首页?

{if $top_parentid==0}
//首页地址
<a href="{siteurl($siteid)}"><div class="menu menu_sel">首页</div></a>
{else}
<a href="{siteurl($siteid)}"><div class="menu">首页</div></a>
{/if}

  

7、取时间:(见上一篇随笔)
{$inputtime}

8、取浏览数:

span id="hits"></span>次
<!--浏览数的js-->
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>

  

9、取上一篇和下一篇:

{$previous_page[title]}
{$next_page[title]}

  

10:截取

{php list ($copyfrom)=explode('|',$v['copyfrom'])}{$copyfrom}

  

11:分页

{pc:content action="lists" catid="60" order="listorder ASC" num="3" moreinfo="1" page="$page"}
{/pc}

  

分页的地方加:{$pages}

05-02 19:51