Get current page in sidebar pagination inside a panel field

In the $_session I can see this value. It is 4 and this is the correct pagination page number. That key is hard to use because of the hash number.

[pages.3013f9fce33116fecffe64915c48ac2c91e00d49] => 4

I bet there is a better way to get the panel pagination current page number?

Update

There is a get variable as well but that is not always visible. In some cases the panel relys in the session only.

Update 2

This seems to work:

$children = $this->page->children();
$children = $children->paginated('sidebar');
$pagination = new Snippet('pagination', array(
	'pagination' => $children->pagination(),
	'nextUrl'    => $children->pagination()->nextPageUrl(),
	'prevUrl'    => $children->pagination()->prevPageUrl(),
));

print_r($pagination->{'_data'}['pagination']->page());

But this is very ugly:

print_r($pagination->{'_data'}['pagination']->page());

Any way of doing it nicer?

What about get('page')?

It does not work when I remove the get variable from the url.

I will solve this case differently anyway. I will use my own get variables for the pagination, not the built in one.

1 Like