PHPCMS的基础代码

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

1、取栏目名称:

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

 

2、取栏目地址:

{$CATEGORYS[$catid][url]}

  

3、取一级栏目:

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

  

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

1
2
3
4
5
6
7
8
9
10
11
{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}

  


加判断:

1
2
3
4
5
6
7
8
9
10
11
{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、取内容:

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

  

灵活运用: 

1
2
3
4
5
6
7
8
9
10
{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}

  

1
2
3
4
5
6
7
8
9
{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、判断是否为首页?

1
2
3
4
5
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、取浏览数:

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

  

9、取上一篇和下一篇:

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

  

10:截取

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

  

11:分页

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

  

分页的地方加:{$pages}

转载于:https://www.cnblogs.com/nzhcww/p/7092705.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值