Define a function to split a list of items into pages, and use it in the views.