开发者

Drupal Views Pager

开发者 https://www.devze.com 2023-01-15 18:59 出处:网络
I\'m using the views built in pager and would like to have an option to \'Show All\'.i.e. Show All< 开发者_如何学GoPrev | Next > Page 2 of 10.

I'm using the views built in pager and would like to have an option to 'Show All'. i.e. Show All < 开发者_如何学GoPrev | Next > Page 2 of 10.

What would be the best way to achieve this?

Steve


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消