You are here

function flippy_pager_block in Flippy 7

Render the Flippy pager block.

Parameters

$delta: The delta passed into hook_block_view(). This will specify whether or not we this block should render a pager for all enabled node types or just the specific type requested.

Return value

A renderable block array.

1 call to flippy_pager_block()
flippy_block_view in ./flippy.module
Implements hook_block_view().

File

./flippy.module, line 623
Allows administrators to add previous/next pagers to any node type.

Code

function flippy_pager_block($delta = '') {

  // Detect if this pager should be for all nodes or just a given type
  if (strstr($delta, 'flippy_pager-node_type-')) {
    $type = str_replace('flippy_pager-node_type-', '', $delta);

    // If $type isn't a content type we know it was hashed so must rehash to find the type
    $types = node_type_get_names();
    if (!array_key_exists($type, $types)) {
      foreach ($types as $machine => $name) {
        $hash = flippy_block_hash_delta($machine);
        if ($delta == $hash) {
          $type = $machine;
        }
      }
    }
  }
  else {
    $type = NULL;
  }

  // Detect if we're viewing a node
  if ($node = menu_get_object('node')) {

    // See if this node matches the type requested
    if (!$type || $type == $node->type) {

      // Make sure this node type is still enabled
      if (_flippy_use_pager($node)) {

        // Generate the block
        $block = array(
          'subject' => NULL,
          'content' => theme('flippy', array(
            'list' => flippy_build_list($node),
          )),
        );

        // Set head elements
        _flippy_add_head_elements($node);
        return $block;
      }
    }
  }
  return NULL;
}