Steven Cheng
Steven Cheng

Reputation: 1081

Drupal Views Pager

I'm using the views built in pager and would like to have an option to 'Show All'. i.e. Show All < Prev | Next > Page 2 of 10.

What would be the best way to achieve this?

Steve

Upvotes: 2

Views: 3350

Answers (2)

mpdonadio
mpdonadio

Reputation: 2941

When I do this, I usually also need to add in something to change the number of results displayed. I do something like

function mymodule_views_pre_build (&$view)
{    
   if (isset($_GET["perpage"])) {

    $perpage = check_plain($_GET["perpage"]);

    if (is_numeric($perpage) && (int) $perpage > 1) {
        $view->pager["items_per_page"] = (int) $perpage;
    } else if ($perpage == "all") {
        $view->pager["use_pager"] = false;
        $view->pager["items_per_page"] = 0;
    }
}

Edit as needed to only affect the views you want/need.

Upvotes: 2

Jo&#227;o Guilherme
Jo&#227;o Guilherme

Reputation: 1379

Steven, you can clone your actual display and on the new one you remove the pager. On the original view, you should theme the pager to add a link to the "Show all" (that would link to the cloned view). This seams to be the simpler solution for me.

Upvotes: 5

Related Questions