PHPCMS常用代码

1、分页:

$page = max(intval($page), 1);
        $pagesize = 10;    
        $offset = $pagesize*($page-1);
        $limit = "LIMIT $offset, $pagesize";
        $data=$db->select("select * from cms_yp_category where kind=$kind order by orderid $limit");
        $datas=$db->get_one("select  count(* ) as num from cms_yp_category where kind=$kind");
        $pages = pages($datas[num], $page, $pagesize);

2、栏目名称:$CATEGORY[$catid]['catname'];

V9获取子栏目:
该方法不是任何页面使用都有效,还不知道为什么?
 {php  $subcatid=array();}   //这句要视情况要不要加,指的是定义他为数组。
      {loop subcat(15)  $k $v}
        {php $subcatid[] = $k;}
      {/loop}
如果发现上述方法无效则合使方法2:
   {pc:content action="category" catid="$parentid" num="25" siteid="$siteid" order="listorder ASC"}
           {loop $data $r}
           <a href="{$r[url]}">{$r[catname]}</a><span>|</span>
           {/loop}
           {/pc}

3、在pc:content 中增加搜索条件
{php $_where = "typeid=" . $_typeid}
{pc:content action="lists" catid="34" num="10" order="id DESC" page="$page" where="$_where"}

4、V9后台会员调用模型表数据
//查询模型数据表
$this->db->set_model($modelid);
$member_modelinfo = $this->db->listinfo($where_info);

5、类别名称:$TYPE[$typeid]['name']

6、过滤HTML标签:

<?php 
$str = preg_replace( "@<script(.*?)</script>@is", "", $r[content] ); 
$str = preg_replace( "@<iframe(.*?)</iframe>@is", "", $str ); 
$str = preg_replace( "@<style(.*?)</style>@is", "", $str ); 
$str = preg_replace( "@<(.*?)>@is", "", $str ); 
?> 
{$str}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值