Dear all,
I have a question regarding the pager count problem that I faced when I tried to take away some rows from the views through the function "hook_views_pre_render".
So my scenario right now is:
At first there should be 152 records, but after I did some changes in hook_views_pre_render, the final result is 148 now.
The pager I've set is 30 per page, so in the original setting (152) there should be 6 pages, and after doing changes in hook_views_pre_render, it should only have 5 pages (148 records).
But I found no way to change the total count of the records for the pagination thing. Any idea?
Thanks a lot!
Gordon
Comments
Comment #1
dawehnerThere is currently no hook after the count query and setting up the pager variables
So i fear you have to set up it for yourself. This is code out of includes/view.inc::execute
Comment #2
gortang CreditAttribution: gortang commentedThanks so much dereine!
I solved the problem by adding these lines to my module's prerender code:
Thanks a lot!
Cheers,
Gordon
Comment #3
maria_zk CreditAttribution: maria_zk commentedI have exactly the same problem!
Could you please share some more info on how you people solved this? Maybe some code?
This does nothing in my views pre render case:
The counter here counts the removed items like
So in the end, the $pager_total_items gets the correct sum of results...
Help, please?
Comment #4
avr CreditAttribution: avr commentedI ran into this issue. At least in D7 and in my case, I didn't need to mess with the global
$pager_XXXX
arrays.Instead, after making your changes to the number of rows, just update the
total_items
and then use theupdate_page_info()
function.So, in the end you have:
Comment #5
JMM75 CreditAttribution: JMM75 commentedThank you so much! I've been searching for the problem now for hours. I was missing the call to update_page_info() in my hook_views_pre_render.
Comment #6
christiemade CreditAttribution: christiemade commented#4 was exactly what I needed to get this working with D7. Thanks for passing this on!
Comment #7
christiemade CreditAttribution: christiemade commented#4 was exactly what I needed to get this working with D7. Thanks for passing this on!
Comment #8
christiemade CreditAttribution: christiemade commented#4 was exactly what I needed to get this working with D7. Thanks for passing this on!
Comment #9
Jason Dean CreditAttribution: Jason Dean commentedI don't understand how the solution in #4 can work, either using hook_views_pre_render() or hook_views_post_execute().
For example, let's say my view uses a pager with 10 results per page. Using either hook, I can modify the contents of the $view->result array (remove some unwanted results). But $view->result only contains 10 results, for the page that I am on.
So using the code example above:
What do I set total_items to? These hooks only give me 10 results at a time to modify.
Thanks!