I would like to create a conditional within a views template page I've created where certain content will display based on the current page the pager is on.

The pager adds its own arguments to the URL like so: www.website.com/frontpage?page=1 which would be the 2nd page of content.

So essentially I want the conditional to say if the current page is > 0 show Content B, otherwise show Content A.

I'm stuck at the point where I don't know how to get that page number into my conditional.

Comments

merlinofchaos’s picture

Status: Active » Fixed

$view->query->pager->current_page

Note that nothing there is guaranteed to be set because 1) the current pager may not support paging (i.e, no pager) and the pager may not be initialized. Though if you're in a template, any paging should already have happened since this is during render phase. I would recommend code like this, though:

  $current_page = isset($view->query->pager->current_page) ? $view->query->pager->current_page : 0;

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

phponwebsites’s picture

How to set current page for views via ajax in drupal 7?
Is it possible to set current page for views using Ajax?
Like Drupal.Views.Ajax.page = 1

RoslinMary’s picture

Issue summary: View changes