Drupal 7.x & Dynamic Pager IDs?

I’m working on a block View that is displayed multiple times on the same page. Everything works great except their corresponding pagers… What happens is that I’ll go to click the “Next” button and the next “pager page” of results is empty. It doesn’t happen to every block but enough of them that I believe a pattern exists–just one I’m not able to completely wrap my head around yet.

I suspect (as do others I’ve brought this to the attention of) that this is due to the Pager ID having conflicts with the multiple blocks that have been embedded on the page from the same view. Bearing in mind that multiple view instances exist on this page, it would make sense that the Pager ID would need to be substituted with some sort of dynamic value, but if this is the case, I’m not sure how to go about changing it because I’ve tried using something like rand(1, 1000) inside HOOK_views_pre_build() as a means of testing the idea but it doesn’t seem to have the correct outcome (i.e. - when I do this, the pager doesn’t seem to work at all).

Thoughts?

Under pager there is an option to specify a pager ID that is meant to address this very problem.

But does that also handle multiple instances of the same view on the same page? I’ve embedded the view on the page inside a loop and in each iteration I pass into the block view a department parameter to generate corresponding staff lists.

I’ve tried adjusting that ID setting (tried both ‘2’ and ‘9999’) but I still have issues with the pager’s NEXT button on some of the blocks that get generates and I’ve noticed that the problems often happen to the blocks where I pass in a department that has ampersands in the parameter I use in the embed_view call.

For example, if in the module file I use “views_embed_view(‘staff_block’, ‘block’, ‘Sales & Marketing’)”, the view will show up okay and the staff will be generated as expected, but as soon as I press the “Next” button, the view (minus its corresponding filter) simply disappears.

Any thoughts on why this is happening? If this is an escaping / URL encoding issue, I don’t understand why the view would initially show up okay but when I use the pager’s NEXT button, suddenly it bombs. So weird…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.