Check If Book Node Is the Parent Of Another
Last modified: October 5, 2006 - 13:41
<?php
function check_book_parent($nid, $parent) {
$sql = "SELECT nid, parent FROM {book} WHERE nid = %d";
$query = db_query($sql, $nid);
$result = db_fetch_object($query);
if ( $result->parent == $parent) {
return true;
} else {
return false;
}
}
?>This function can be placed in your Template.php (if using the PHPTemplate Theme Engine but the PHPTemplate Theme Engine is not required for this function). This function requires the Book Module.
This function requires 2 nid values($nid, $parent) for quick checking if one node is the parent of another.
Example of this function being used in node-book.tpl.php
<?php
if (check_book_parent($node->nid, $parent->nid)) {
// code
}
?>