1

Why does the Views module accep uses the number of items per page that is in pre-defined sets like 5, 10, 25, 50, and doesn't accept values outside those values?

I know how to change it; I just need an explanation.

3

To be brutally simple: Because someone thought it to be good UX, maintainers agreed, and no one convinced them other way since then. That's all to it.


There are many reasons for drop-down instead of text field. For example simplicity. User cannot enter bad values, so there is no need for bad value handling. Testing - you can programatically set other amounts, all right, but there you have ones they tested their module for, and take some responsibility that they work properly. Of course, maybe someone simply liked it that way. No way to know for sure what was the most important part in this decision.

1

You can do it by using views_pag_views_pre_build()

function views_pag_views_pre_build(&$view) {
    if ($view->name == "pagination") {
            $view->init_pager();
            $view->set_items_per_page('10');

    }
}

Reference Human Love

  • I am not asking about how to do it, but why? – Mohammed Gomma Dec 29 '15 at 13:24
  • I'm pretty sure that argument passed to set_items_per_page should be an integer. Of course PHP will cast it silently, but anyway no need for string constant where integer value is needed. – Mołot Dec 29 '15 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.