You are here

function themekey_book_get_simple_book_property in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 modules/themekey.book.inc \themekey_book_get_simple_book_property()
  2. 6.2 modules/themekey.book.inc \themekey_book_get_simple_book_property()
  3. 6.3 modules/themekey.book.inc \themekey_book_get_simple_book_property()
  4. 7 modules/themekey.book.inc \themekey_book_get_simple_book_property()
  5. 7.2 modules/themekey.book.inc \themekey_book_get_simple_book_property()

Helper function that loads a book and returns the value of a book's property.

Parameters

$nid: a node id

$property: name of a nodes attribute as string

Return value

the value of the property or NULL

2 calls to themekey_book_get_simple_book_property()
themekey_book_nid2bid in modules/themekey.book.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
themekey_book_nid2has_children in modules/themekey.book.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).

File

modules/themekey.book.inc, line 108
Provides some comment attributes as ThemeKey properties.

Code

function themekey_book_get_simple_book_property($nid, $property) {
  static $books = array();
  if (!isset($books[$nid])) {
    $nodes = array(
      $nid => new stdClass(),
    );

    // node_load() must not be called from hook_init().
    // Therefore we have to execute SQL here using book's hook_node_load().
    book_node_load($nodes, NULL);
    if (isset($nodes[$nid]->book)) {
      $books[$nid] = $nodes[$nid]->book;
    }
    else {
      $books[$nid] = array();
    }
  }
  if (isset($books[$nid][$property])) {
    return $books[$nid][$property];
  }
  else {
    return NULL;
  }
}