1
Hi, there
Today I was in need to pass an html anchor (#something) to XoopsPageNav, the easiest way was to pass it after the url generation, as the #anchors need to be at the end of an url string.
So, I've changed a little the renderNav function (only an $anchor added 4 times), maybe it can be usefull for someone or something - and maybe we can have a pagenav class that pass #anchors in future versions.
here the code..
function renderNav($offset = 4, [color=FF0000]$anchor[/color])
{
$ret = '';
if ( $this->total <= $this->perpage ) {
return $ret;
}
$total_pages = ceil($this->total / $this->perpage);
if ( $total_pages > 1 ) {
$prev = $this->current - $this->perpage;
if ( $prev >= 0 ) {
$ret .= '.$this->url.$prev.[color=FF0000]$anchor.[/color]'">« ';
}
$counter = 1;
$current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
while ( $counter <= $total_pages ) {
if ( $counter == $current_page ) {
$ret .= '('.$counter.') ';
} elseif ( ($counter > $current_page-$offset && $counter < $current_page + $offset ) || $counter == 1 || $counter == $total_pages ) {
if ( $counter == $total_pages && $current_page < $total_pages - $offset ) {
$ret .= '... ';
}
$ret .= '.$this->url.(($counter - 1) * $this->perpage).[color=FF0000]$anchor.[/color]'">'.$counter.' ';
if ( $counter == 1 && $current_page > 1 + $offset ) {
$ret .= '... ';
}
}
$counter++;
}
$next = $this->current + $this->perpage;
if ( $this->total > $next ) {
$ret .= '.$this->url.$next.[color=FF0000]$anchor.[/color]'">» ';
}
}
return $ret;
}
Note: the value passed is a complete html anchor, it mean that you need to pass '#anchor' instead of simply 'anchor'.
Maybe someone will need a modified version of this -> I'm looking at XXbit charset users..
banned,