示例#1
0
function get_hierarchy($array, $count, $x = 0)
{
    if ($array[$x]) {
        $html = '<ul>';
        foreach ($array[$x] as $key => $value) {
            $html .= '<li>';
            $html .= '<a href="' . href(explode(",", $array[$x][$key][1])) . '">' . $array[$x][$key][0] . '</a>';
            $html .= get_hierarchy($array, $count, $key);
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    return $html;
}
示例#2
0
    $list_class = "{$list_class} {$vars['list_class']}";
}
$item_class = "elgg-category";
if (isset($vars['item_class'])) {
    $item_class = "{$item_class} {$vars['item_class']}";
}
$icon_class = elgg_extract('icon_class', $vars);
$list_items = '<li>' . elgg_view_icon('categories', $icon_class) . '</li>';
foreach ($vars['categories'] as $category) {
    if (!elgg_instanceof($category, 'object', HYPECATEGORIES_SUBTYPE)) {
        continue;
    }
    $children = get_subcategories($category->guid, array('count' => true));
    if ($children > 0) {
        continue;
    }
    $crumbs = array();
    $hierarchy = get_hierarchy($category->guid, false, true);
    foreach ($hierarchy as $h) {
        $crumbs[] = $h->title;
    }
    $list_items .= "<li class=\"{$item_class}\">";
    $list_items .= elgg_view('output/url', array('href' => $category->getURL(), 'title' => implode(" &#8227; ", $crumbs), 'text' => $category->title));
    $list_items .= '</li>';
}
$list = <<<___HTML
<ul class="{$list_class}">
\t{$list_items}
</ul>
___HTML;
echo $list;