取得offset
<?php
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
$intCount = 1000 ; // 假设记录总数为1000
$intShowNum = 10 ; // 每页显示10
$aPDatas = $pBP->get( $intCount, $intShowNum );
$offset = $aPDatas['offset'] ;
?> |
非数据库分页:
比如有一篇文章长度是10000字节,要想每2000字节分为一页,那怎么办呢?
<?php
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
$strLen = strlen($strSubContent); //假设内容总长度,这个自己计算取得
$strSubLen = 2000 ; // 每页数据长度
$aPDatas = $pBP->get( $strLen, $strSubLen );
$offset = $aPDatas["offset"] ;
//取得当前页的内容
$strSubContent = fn_substr( $strSubContent, $offset , $strSubLen ) ; //截取函数自己写
?> |
一些属性:
8.1 你使用的变量不是page,而是其他,比如是 pn :
<?php
$pBP->_var = 'pn' ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.2 $this->_prefix有什么作用?
当你的分页是类似于page=pp123这样的数字前面有字符的时候,$this->_prefix就有用了
<?php
$pBP->_prefix = 'pp' ; // 如page=pp123的 pp
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.3 $this->_postfix有什么作用? :
当你的分页是类似于page=123p这样的数字后面有字符的时候,$this->_postfix就有用了
<?php
$pBP->_postfix = 'p' ; // 如page=123p的 p
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.4 $this->_prefix和$this->_postfix能否同时使用? :
当然可以。当你的分页是类似于page=pn123ccc 这样的数字后面有字符的时候,就两个一起用
<?php
$pBP->_prefix = 'pn' ;
$pBP->_postfix = 'ccc' ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.5 $this->_pos有什么用? :
它的作用是 当前页在分页条中的位置设定,比如设为3,当前页是8,那么数字8就分处在分页条的第三位即: 6 7 8 9 10 11 12 13 14 15
<?php
$pBP->_pos = 5 ; //把当前页放到第五位
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.6 $this->_symbol有什么用? :
连接符
<?php
$pBP->_symbol= '&' ; //使用&为链接符
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.7 $this->_getqs有什么用? :
是否取得Query String。默认取得,为false则不取得。可节省资源,但如果要取得链接与html的时候,它会为true
<?php
$pBP->_getqs = false ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.8 $this->_getlink有什么作用? :
this->_getlink默认为true,即表示取得分页的链接,为false时,有关*ln键名的变量,都不会有值它的作用在于,1 适用于手工设置链接的人 2 节省资源
<?php
$pBP->_getlink = false ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
8.9 $this->_encode有什么作用? :
$this->_encode默认为true,即表示使用htmlspecialchars对Query String过滤
<?php
$pBP->_encode= false ;//不过滤query string
$aPDatas = $pBP->get( $intCount, $intShowNum );
?> |
最后:
关于BluePage.default.inc.php配置文件
共3页 第1页 第2页 第3页