<?php if ($tree = category::get_tree()) : ?>
    <?php
    $render = function(array &$tree, $parent = 1, array $attribute = array(), $top = false, $path = '') use (&$render)
    {
        echo '<ul';
        
        foreach ($attribute as $k => $v)
        {
            echo ' ', $k, '="', htmlspecialchars($v), '"';
        }
        
        echo '>';
        
        foreach ($tree[$parent] as $c)
        {
            echo '<li' . (($top) ? ' class="box"' : '') . '>';
            echo '<a href="product/index/' . htmlspecialchars($path . $c['path']) . '"' . (($top) ? ' class="title"' : '') . '>' . htmlspecialchars($c['name']) . '</a>';
            
            if (array_key_exists($c['id'], $tree))
            {
                $render($tree, $c['id'], array(), false, ltrim($path . '/' . $c['path'] . '/', '/'));
            }
            
            echo '</li>';
        }
        
        echo '</ul>';
    };
    ?>
    <?php $render($tree, 1, array('class' => 'module_' . $module['id']), true); ?>
    <link rel="stylesheet" type="text/css" href="/extend/widget/treeview/jquery.treeview.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo substr(__DIR__, strlen(getcwd())) . '/' . $module['alias']; ?>/skin/style.css" />
    <script src="extend/widget/treeview/jquery.treeview.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(document).ready(function($){
            $('.module_<?php echo htmlspecialchars($module['id']); ?>').treeview({
                persist: 'location',
                collapsed: true,
                unique: false
            });
        });
    </script>
<?php endif; ?>