public function draggableviews_hierarchy_handler_book::get_depth in DraggableViews 7.2
File
- draggableviews_book/
handlers/ draggableviews_hierarchy_handler_book.inc, line 25
Class
Code
public function get_depth($field, $index) {
$row = $field->view->result[$index];
// Cache depth of the top parent so we do not recalculate it.
static $parent_depth;
if (is_null($parent_depth)) {
$parent_mlid = $row->draggableviews_book_plid;
$parent_depth = db_query('SELECT depth FROM {menu_links} WHERE mlid = :mlid', array(
':mlid' => $parent_mlid,
))
->fetchField() + 1;
}
return isset($row->draggableviews_book_depth) ? $row->draggableviews_book_depth - $parent_depth : 0;
}