You are here

function headerimage_eval_book in Header image 6

Same name and namespace in other branches
  1. 5 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 306
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 (books)
    $match = in_array(arg(1), $condition);
    if ($match) {
      return true;
    }

    // check if current page is part of book in the condition pages
    $bid = db_result(db_query("SELECT bid FROM {book} WHERE nid = %d", arg(1)));
    $match = in_array($bid, $condition);
  }
  return $match;
}