function custom_pagers_nodeapi in Custom Pagers 5
Same name and namespace in other branches
- 6 custom_pagers.module \custom_pagers_nodeapi()
File
- ./
custom_pagers.module, line 45
Code
function custom_pagers_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
// We want to make sure we don't try to output when print.module is active.
// It's a bit of special casing but it doesn't do much harm.
if ($teaser == false && !$node->printing) {
$pagers = _custom_pagers_load_all_pagers();
foreach ($pagers as $pager) {
if ($pager->position != 'block' && _custom_pagers_visibility($pager, $node)) {
$nav_array = custom_pager_build_nav($pager, $node);
if ($nav_array['current_index'] != -1) {
$output = theme('custom_pager', $nav_array, $node, $pager);
switch ($pager->position) {
case 'top':
$node->content['custom_pager_top'][$pager->pid] = array(
'#value' => $output,
);
break;
case 'bottom':
$node->content['custom_pager_bottom'][$pager->pid] = array(
'#value' => $output,
);
break;
case 'both':
$node->content['custom_pager_top'][$pager->pid] = array(
'#value' => $output,
);
$node->content['custom_pager_bottom'][$pager->pid] = array(
'#value' => $output,
);
break;
}
}
}
}
if (isset($node->content['custom_pager_top'])) {
$node->content['custom_pager_top']['#weight'] = -100;
}
if (isset($node->content['custom_pager_bottom'])) {
$node->content['custom_pager_bottom']['#weight'] = 100;
}
}
break;
case 'update':
case 'insert':
case 'delete':
// If a user makes any changes to a node, we want to make sure that
// their pager cache is cleared. It's ugly, but it should prevent some
// of the nastier cache-went-stale issues.
unset($_SESSION['custom_pagers']);
break;
}
}