$parent = Dom::node(); } // object to render at the end of the script $dom = $parent; // add current parent to the stack $stack[] = $parent; // current depth $currentDepth = $startDepth; // loop through items for ($i = 0, $count = count($data); $i < $count; $i++) { // get item $item = $data[$i]; // get depth $depth = $item->data('depth') + $startDepth; // create item html $menuItem = Dom::fragment(View::factory('menu/item/base', array('item' => $item, 'alias' => $alias, 'depth' => $depth))->render()); // calulate depth difference $depthDiff = $depth - $currentDepth; // update current depth $currentDepth = $depth; // lookup or create the correct parent to add the item to if ($depthDiff > 0) { if (isset($nodeBranch)) { // use nodebranch as template $newParent = clone $nodeBranch; } else { // create ul node $newParent = Dom::node('ul'); } // append class $newParent->attribute('class', 'menuLevel' . $depth, TRUE);
$keys = ''; foreach ($viewer->keys($item) as $key) { // truncate $value = isset($key->truncate) ? Tool::truncate_html($key->value, $key->truncate, '...') : $key->value; if ($view = $key->view) { $keys .= View::factory('list/key/' . $view, array('key' => $key, 'item' => $item))->render(); } elseif ($link = $key->link) { $keys .= HTML::anchor(URL::to($link[0], $link[1], $link[2]), $value); } else { $keys .= $value; } } $div->append(Dom::fragment($keys)); // set tools $tools = $viewer->tools($item); $div->append(Dom::fragment($tools)); // calulate depth difference $depthDiff = $depth - $currentDepth; // update current depth $currentDepth = $depth; // loopup or create the correct parent to add the item to if ($depthDiff > 0) { // create new parent with an UL $newParent = Dom::node('ul'); // add it to the last created li $parent->last_child()->append($newParent); // set the newly created element as the new parentelement $parent = $newParent; // add this parent to the stack $stack[] = $parent; } elseif ($depthDiff == 0) {