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}