1 (edited by 2013-08-11 18:20:54)

Topic: Custom Pagination

I've been using the following code for news pagination and after updating cutnews I found that it generates a different url for the page numbers. could someone rewrite it for the latest version of cutenews? it is really important for me that it displays a smaller number of pages as I have over 100.

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>
    //----------------------------------
    // Pages
    //----------------------------------
    if ($number){
    $total_pages = @ceil($count_all / $number);
    $current_page = ($start_from/$number) + 1;
    $pages = '';

    //Advanced pagination
    if ($total_pages > 20){
    //Left block
    $pages_start = 1;
    $pages_max = $current_page >= 10 ? 1 : 10;
    for($j = $pages_start; $j <= $pages_max; $j++){
    if($j == $current_page){
    $pages .= ''.$j.' ';
    }
    else{
    $pages .= '[url=]    '&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' [/url]';
    }
    }
    $pages .= '... ';

    //Middle block
    if($current_page > 9 && $current_page < ($total_pages - 8)){
    $pages_start = $current_page - 5;
    $pages_max = $current_page + 5;
    for($j = $pages_start; $j <= $pages_max; $j++){
    if($j == $current_page){
    $pages .= ''.$j.' ';
    }
    else{
    $pages .= '[url=]    '&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' [/url]';
    }
    }
    $pages .= '... ';
    }

    //Right block
    $pages_start = $current_page <= $total_pages - 9 ? $total_pages : $total_pages - 9;
    $pages_max = $total_pages;
    for($j = $pages_start; $j <= $pages_max; $j++){
    if($j == $current_page){
    $pages .= ''.$j.' ';
    }
    else{
    $pages .= '[url=]    '&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' [/url]';
    }
    }
    }

    //Normal pagination
    else {
    for ($j = 1; $j <= $total_pages; $j++){
    if ((($j - 1) * $number) != $start_from){
    $pages .= '[url=]    '&archive='.$url_archive.'&subaction='.$subaction.'&id='.$id.'&'.$user_query.'">'.$j.' [/url] ';
    } else {
    $pages .= ' '.$j.' ';
    }
    }
    }

    $prev_next_msg = str_replace('{pages}', $pages, $prev_next_msg);
    }
</div>