1 (edited by 2009-01-22 14:15:31)

Topic: [HACK] Dropdown menu for pagination

Name: Dropdown menu for pagination
Author: Asriel86
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: If you want to be able to list your pagination as a dropdown box, where selecting one of the page numbers from the dropdown automaticaly goes to that page.
Demo: This is demonstrated currently at www.aarondunlap.com
Instructions:

in shows.inc.php find the following block of code (should be around line 782):

    //----------------------------------
    // Pages
    //----------------------------------
    if($number){
    $pages_count = @ceil($count_all/$number);
    $pages_start_from = 0;
    $pages = "";
    for($j=1;$j<=$pages_count;$j++){
        if($pages_start_from != $start_from){ $pages .= "[url=]$j[/url] "; }
                else{ $pages .= " <strong>$j</strong> "; }
        $pages_start_from += $number;
        }
        $prev_next_msg = str_replace("{pages}", $pages, $prev_next_msg);
        }

add the following code below that:

    //----------------------------------
    // Pages || Modified for dropdown
    //----------------------------------
    if($number){
     $pages_count = @ceil($count_all/$number);
     $pages_start_from = 0;
     $pages = "<select class=\"cn-pagedrop\" name=\"gotopage\" onchange=\"window.location.href = document.all.gotopage.value;\">";
     $currentpage = $start_from / $number + 1; 
     for($j=1;$j<=$pages_count;$j++){
  if ($currentpage == $j) { $pages .= "<option selected value=\"$PHP_SELF?start_from=$pages_start_from&ucat=$ucat&archive=$url_archive&subaction=$subaction&id=$id&page=$j&$user_query\">$j</option> "; }
  else { $pages .= "<option value=\"$PHP_SELF?start_from=$pages_start_from&ucat=$ucat&archive=$url_archive&subaction=$subaction&id=$id&page=$j&$user_query\">$j</option> "; }       
         $pages_start_from += $number;
     }
     $pages .= "</select>";
     $prev_next_msg = str_replace("{pages-dropdown}", $pages, $prev_next_msg);
    }

Now you can use the tag {pages-dropdown} to insert the dropdown box.

Re: [HACK] Dropdown menu for pagination

Wow big_smile Very neat - great work there Asriel!