10000, //initial count #, must be higher than expected max number of pages in list 'perpageitems' => 20, //set number of pagelist items to be displayed per page 'urlargkey' => 'p', //set key used for url parameter 'words' => array( 'res' => 'Results', 'pg' => 'Page', 'of' => 'of', 'go' => 'Go to page', 'nxt' => 'Next', 'prv' => 'Previous', ), )); # Page variable {$BPLRange} for (:pagelist .... count={$BPLRange} :) to set range of pages $FmtPV['$BPLRange'] = 'BreakPageList($pagename, "range")'; # fmt=bplnavlinks for pagelist to generate $BPLPageCount and create nav links # by calling BreakPageList() SDVA($FPLFormatOpt['bplnavlinks'], array('fn' => 'BPLNavLinks')); function BPLNavLinks($pagename, &$matches, $opt) { global $BPLConfig; $matches = array_values(MakePageList($pagename, $opt, 0)); $BPLConfig['count'] = count($matches); return BreakPageList($pagename, 'links', $opt); } //}}} # dual use function: # calculate 'range' for (:pagelist ..... count={$BPLRange} :), # generate navigation links to page chunks for (:pagelist .... fmt=bplnavlinks:) function BreakPageList($pagename, $opt, $args='') { global $BPLConfig; $res = $BPLConfig['count']; $ppi = $BPLConfig['perpageitems']; $key = $BPLConfig['urlargkey']; $wds = $BPLConfig['words']; $wdres = ($args['bplresults']) ? $args['bplresults'] : $wds['res']; if($ppi==0) $ppi=1; //prevent div by zero error $pmax = ceil(intval($res)/$ppi); if ($pmax<=0) $pmax=1; $p = @$_REQUEST[$key]; if ($p<1) $p=1; if ($p>$pmax) $p=$pmax; $from = ($p-1)*$ppi+1; $to = $p*$ppi; $range = $from."..".$to; switch($opt) { case 'range': return $range; case 'links': if (isset($args['bplpre'])) $nav = $args['bplpre']; elseif ($pmax > 1) $nav = "$res $wdres – {$wds['pg']} $p {$wds['of']} $pmax – {$wds['go']}"; else $nav = "$res $wdres – {$wds['pg']}"; $prev = $p-1; if ($prev>0) $nav .= " [[$pagename?$key=$prev|{$wds['prv']}]]"; for($i=1; $i<=$pmax; $i++) { if ($i==$p) $nav .= " $p"; elseif (($i==$p-3 && $i>1) OR ($i==$p+3 && $i<$pmax)) $nav .= " ..."; elseif ($i==$p-1 || $i==$p+1 || $i==$p-2 || $i==$p+2 || $i==1 || $i==$pmax) $nav .= " [[$pagename?$key=$i|$i]]"; } $next = $p+1; if ($next<=$pmax) $nav .= " [[$pagename?$key=$next|{$wds['nxt']}]]"; $nav .= " ".@$args['bplsuf']; return $nav; } } //}}}