function paging_render_names in Paging 6
Returns a rendered list of page links.
Parameters
$nid: Node ID to render page links for.
1 call to paging_render_names()
- paging_block in ./
paging.module - Implementation of hook_block().
File
- ./
paging.module, line 364 - Allows users to use a tag to break up a node into multiple pages.
Code
function paging_render_names($nid = NULL) {
global $pager_page_array, $pager_total;
// Load node ID form URL, if none was supplied.
$nid = $nid ? $nid : arg(1);
// Fetch a structured array containing page names.
$names = paging_fetch_names($nid);
// Load the node object to counting total number of expected pages.
$node = node_load($nid);
// Invoke 'load' operation in hook_nodeapi() implementation to calculate the actual number of pages in the node body.
paging_nodeapi($node, 'load');
// Comparing and mapping the number of pages in $names and $node->page_count.
$fake = array_fill(0, ($node->page_count - 1 < 1 ? 1 : $node->page_count - 1) + 1, '');
$length = count($fake) > count($names) ? count($fake) : count($names);
for ($i = 0; $i < $length; ++$i) {
$merged[$i] = $names[$i];
}
// Fill the empty names with node title and page number.
$names = _paging_populate_empty_names($merged, $node->title);
$rendered_links = array();
// Element value to distinguish between multiple pagers on one page.
$element = 1;
// Get the current position.
$pager_current = $pager_page_array[$element] + 1;
// Convert the names into links.
foreach ($names as $key => $name) {
$page_new = pager_load_array($key, $element, $pager_page_array);
$rendered_links[] = theme('pager_link_item', $name, $page_new, $element);
}
return theme('item_list', $rendered_links);
}