You are here

function custom_pager_build_nav in Custom Pagers 6

Same name and namespace in other branches
  1. 5 custom_pagers.module \custom_pager_build_nav()
  2. 7 custom_pagers.module \custom_pager_build_nav()
2 calls to custom_pager_build_nav()
custom_pagers_block in ./custom_pagers.module
Implementation of hook_block().
custom_pagers_nodeapi in ./custom_pagers.module

File

./custom_pagers.module, line 186
Allows administrators to define context-sensitive previous/next pagers for any node type.

Code

function custom_pager_build_nav($pager, $node) {
  static $pager_cache;
  $list = array();

  // Let's build it from scratch!
  if (empty($list)) {

    // If the pager uses PHP, execute the PHP and run with the list.
    // Otherwise, use a view to get a list of node ids.
    if (!empty($pager->list_php)) {

      // Use PHP code to generate the list.
      ob_start();
      $result = eval(trim($pager->list_php));
      if (is_array($result)) {
        $list = $result;
      }
      ob_end_clean();
    }
    elseif ($results = custom_pagers_get_list_from_view($pager, $node)) {
      $list = $results;
    }
    if ($pager->reverse_list) {
      $list = array_reverse($list);
    }
  }
  return pager_entries_by_val($node->nid, $list);
}