FuelPHP Bin
<?php public static function get_tree(Model_Section $root, $include_root = false) { // Main UL $output = "\n<ul>"; // Include root name if ($include_root === true) $output .= "\n<li>{$root->name}</li>\n<ul>"; // Recuse through children, if any if ( ! $root->is_leaf()) { // Fetch all children foreach ($root->children()->get() as $child) { // For every child, create an LI $output .= "\n<li>{$child->name}"; // Recurse if it's not a leaf if ( ! $child->is_leaf()) $output .= static::get_tree($child); // Closing LI for item $output .= "\n</li>"; } } // Main UL closing item if ($include_root === true) $output .= "\n</ul>"; $output .= "\n</ul>"; return $output; }