Hallo!
Ich möchte eine Blätterfunktion mit 10 Schritten bauen!
<< | < | 3 4 5 6 7 8 9 10 11 12 13 | > | >>
Momentan gibt er mir alle Seitenanzahlen aus.
Wie kann ich den Bereich eingrenzen?
$page = Seite
$per_page = 50;
$total = "Gesamte Abfrage"; z.B 400
	
							
						
					Ich möchte eine Blätterfunktion mit 10 Schritten bauen!
<< | < | 3 4 5 6 7 8 9 10 11 12 13 | > | >>
Momentan gibt er mir alle Seitenanzahlen aus.
Wie kann ich den Bereich eingrenzen?
$page = Seite
$per_page = 50;
$total = "Gesamte Abfrage"; z.B 400
PHP-Code:
	
	
function smarty_function_paginate($params, &$smarty)
{
    $page=$params['para1'];
    $per_page=$params['para2'];
    $total=$params['para3'];
    $query=$params['para4'];
    
 
    if (!$per_page) return;
    $link = $total / $per_page;
    $links = ceil($link);
    $output="";
    if ($page == "") {
        $page = 1;
    }
    if ($page == "" or $page == 1) {
        $output ="";
    } else {
        $url_query = http_build_query(array("search"=>$query, "page"=>$page-1), "", "&");
        $output .= '<a href="?'.$url_query.'">< Zurück</a>';
    }
    $output .= "  ";
    
    
        for ($i=1; $i<=$links; $i++) {
            if ($i == $page) {
                $output .= "<em>".$i."</em>  ";
            } else {
                $url_query = http_build_query(array("search"=>$query, "page"=>$i), "", "&");
                $output .= '<a href="?'.$url_query.'">'.$i.'</a>  ';
            }
        }
    
    if ($links != $page and $total > 20 ) {
        $url_query = http_build_query(array("search"=>$query, "page"=>$page+1), "", "&");
        $output .= '<a href="?'.$url_query.'">Vorwärts ></a>';
    }
 
    return $output; 
 
          

Kommentar