#1 zhgzzy
模板页调用标签:<{fp a=$results.id p=$p c=$results.content}>
spAddViewFunction('fp','fp'); //注册到模板本人抛砖引玉,还请大家指点,也请高手把好东西分享出来,谢了!!!
function fp($params)
{
$arid = $params['a']; //文章id
$p = $params['p']; //文章分页的当前页码
$contents = $params['c']; // 文章内容
$arr1 = explode('
',$contents); //数组长度&总页数
$arr2 = explode('
',$contents); //数组长度&总页数
if ($arr1 < $arr2){
$arr = $arr2;
}else{
$arr = $arr1;
}
$total = count($arr); //当前页
$nowpage = $p?$p:1; //上页
$pdiv = '';
//$pdiv .= "总{$nowpage}/{$total}页";
for($i = 1; $i<=$total; $i++)
{
$url = spUrl(main,view,array('id'=>$arid,'p'=>$i));
if ($i==$nowpage){
$pdiv .= "{$i}";
} else {
$pdiv .= "{$i}";
}
}
$pdiv .= '
'; //输出内容
echo $arr[$nowpage-1]; //不分页则不显示分页列表
if( $total <=1) $pdiv = ''; //输出分页列表
echo $pdiv;
}
2012-09-13 11:35:12