You are here

function headerimage_eval_book in Header image 7

Same name and namespace in other branches
  1. 5 headerimage.module \headerimage_eval_book()
  2. 6 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 403
headerimage.module Conditionally display an node in a block.

Code

function headerimage_eval_book($condition) {
  $match = NULL;
  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_select('book')
      ->fields(array(
      'bid',
    ))
      ->condition('nid', arg(1))
      ->fetchField();
    $match = in_array($bid, $condition);
  }
  return $match;
}