I created a block (call it image_views) using views to list images. I use it to navigate the image gallery. To handle many images, the views block has a pager.
The image_views block is located on a sidebar and the image is shown in center content area. (I am using Garland theme).
Now the questions: when I change to the 2nd page (or other pages) in image_views, and select an image to show, the image_views block automatically goes back to page 1. Can I make that views block to remember the page number?
This is probably not unique for image browser. I think any pager-enabled block will always set back to page 1 upon reloading the content. I enabled AJAX in views, it doesn't help.

Comments

samwarren’s picture

If there is no direct solution. A hack maybe done with pager.inc.
Can someone show me the way? I am just learning PHP.
I think this might be made default on pager functions. That is, remember the "$pager_current" when user leave the page and back to it again.
Can we use:

$GLOBALS['pager_current']=$pager_current;
$pager_current=$GLOBALS['pager_current'];

?
Any input from the Drupal/php gurus out there?

Thanks,

couash’s picture

Hi samwarren,

I have the exact same problem and I'm looking for a solution. I was wondering if you had any luck since you posted.

Thanks!

nevosa’s picture

subscribing

satch5841’s picture

No solutions yet?!?

jmrivero’s picture

Been working on get the current pager number from a view displayed as a page and pass it to a block of the same view, so far I got to get the pager number from $_GET['page'].
Using it with the View PHP module I can get it with a php field in the block display.
Now only have to change the pager of the block to keep it synchronized with the page view, working on it ATM.

Im a simple guy in a complex world.

jmrivero’s picture

Ok, think i got it to work.
With Views PHP, set this code in the "Setup code" of a PHP field:

$path = $_GET['page'];
$view->set_current_page($path);

This works for pages with only one pager, if the block and the page view haev both pagers, $path will contain a string like 0,3,4 or so, so you may need to explode it and select the correct value.

Im a simple guy in a complex world.