1
banned
XoopsPageNav->renderNav($offset, $anchor)
  • 2005/12/6 1:20

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


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 ) {
            
$prev $this->current $this->perpage;
            if ( 
$prev >= ) {
                
$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 == || $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 == && $current_page $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,

Login

Who's Online

211 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 211


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits