The "total_rows
" property of my view returns the total rows (22), but not the number of items I have set the view to display (5) (through the Web UI Block->Basic Settings).
How can I get this in a proper way without relying on (the possibly soon to be deprecated "result
" property?
for now Im using
$totalRows = min($view->total_rows, count($view->result));
By default the the result is rendered for the "default" display. If you want it for a particular display then you can use
Does
$view->pager["items_per_page"]
fit your needs? I am not 100% sure when this is available, but I am using it in ahook_views_pre_build()
in a custom module.Here is a good solution that allows to display the total results (works with and without a pager) and also, the number of results on a current page (for example, on page 2 of 10): http://www.midwesternmac.com/blogs/jeff-geerling/views-show-showing-x-x-x
Be warned that this solution doesn't work for block type display, only for a page.
This is always available as:
$view->display['your_display']->display_options['items_per_page']
where
your_display
is replaced by the views display you are using (e.g.page_1
,block_1
, etc). This is available at all stages of building process.