book_location
modules/book/book.module, строка 334
- Версии
- 5
book_location($node, $nodes = array())
Given a node, this function returns an array of 'book node'
objects
representing the path in the book tree from the root to the
parent of the given node.
Параметры
$node
A book node object for which to compute the path.
Возвращаемое значение
An array of book node objects representing the path nodes root to parent of the given node. Returns an empty array if the node does not exist or is not part of a book hierarchy.
Код
<?php
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $node->parent));
if (isset($parent->title)) {
$nodes = book_location($parent, $nodes);
$nodes[] = $parent;
}
return $nodes;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии