You are here

function headerimage_eval_book in Header image 5

Same name and namespace in other branches
  1. 6 headerimage.module \headerimage_eval_book()
  2. 7 headerimage.module \headerimage_eval_book()

Evaluate book condition

Return true if current node is a page of the book(s) selected in the condition

Parameters

$condition: array of book root nid's

Return value

true: current node is a page in $condition's books false: if not null: current page is not a node

1 call to headerimage_eval_book()
headerimage_select_node in ./headerimage.module
Select a node to be displayed in the block

File

./headerimage.module, line 448
headerimage.module Conditionally display an node in a block.

Code

function headerimage_eval_book($condition) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {

    // check if current node is one of the condition pages (book roots)
    $match = in_array(arg(1), $condition);
    if ($match) {
      return true;
    }

    // check if root of current page is one of the condition pages
    $book = book_location(node_load(arg(1)));
    $match = in_array($book[0]->nid, $condition);

    // $book[0] is book root
  }
  return $match;
}