[Drupal] How to change the number of items displayed in a Drupal Views pager number dynamically?
Drupal Views provides pagination options. However at a glance the number of items shown in a page seems to be limited. However there is a way to change the number of times shown in a Views page dynamically. If you want to know how to change the number of items displayed in a Drupal Views pager number dynamically then continue reading.
In one of our Drupal sites we were asked to create a feature in which a list of items were to be programmatically displayed on a page. Each page had to contain only 50 items by default and the rest were to be divided and displayed on other pages via paging. Now our Drupal client had also asked us to provide an option on each page where the user can change the default number of items from 50 to any other value. We knew that this was very easy as Drupal Views itself provides an option to do that.
Follow the steps given below to change a Drupal Views pager number dynamically.
- First go to the Pager options fieldset in the settings page of your Drupal Views
- In the Pager options fieldset you will find an Exposed options fieldset
- Check the 'Expose items per page'
- Next enter the numbers you want shown on the page in the "Exposed items per page options' textbox.
For example 50, 100, 200 etc.
- You will also notice an 'Expose offset' option to skip data from the beginning
- If the option is selected we can specify the number of items to be skipped from the beginning of the data
- Have a look at the screenshot
Hope that helps. If you have any questions regarding Drupal Views then get in touch with us using the Comments form found below