I'm not sure if the module already offers this, but I couldn't find anything in the code or $node object that fit the bill.

Problem: I've got a custom content type with some CCK fields, and I want some of these to appear only on the first page. From a theme perspective, I can't seem to be able to figure out how to find out what the current page is in a clean way, unless I'm missing something. (Can I get at it using the arg() function?)

Possible solution(?): In _paging_nodeapi(), the "view" case, the current page is already being found in order to populate the $node->content['body']['#value']. The section looks like:

global $pager_page_array, $pager_total;
$pager_page_array = explode(',', $page);
$pager_total[$element] = $node->page_count;
$page = isset($pager_page_array[$element]) ? $pager_page_array[$element] : 0;

// Put the current page contents into the node body.
$node->content['body']['#value'] = check_markup($node->pages[$page], $node->format, FALSE);

$page equates to the current page you're on. (starting at 0) I thought it would be useful/clean to just drop that value into the $node object.

global $pager_page_array, $pager_total;
$pager_page_array = explode(',', $page);
$pager_total[$element] = $node->page_count;
$page = isset($pager_page_array[$element]) ? $pager_page_array[$element] : 0;

// Put the current page contents into the node body.
$node->content['body']['#value'] = check_markup($node->pages[$page], $node->format, FALSE);

$node->page_current = $page;

That way I can check the var in my theme and show content appropriately.

If there's another way of doing this, without modifying the module, I'd love to hear it. Otherwise, if it seems useful to have this, then maybe introduce it in the next release? $node->$page_count already exists.

Cheers!

Comments

Gurpartap Singh’s picture

  print substr($_GET['page'], (strpos($_GET['page'], ',') + 1)); // gives you the current page :)
smacphail’s picture

Ugh, thanks. I blame my tendency to over think. :P

Still, a $node->page_current var would be themer friendly, especially for those developers who aren't really up on their PHP.

Gurpartap Singh’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -theme, -current page, -pagination

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