Created
September 21, 2009 19:51
-
-
Save mrkurt/190507 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public static function sort_categories($categories){ | |
if(get_class($categories) == 'ResourceList'){ | |
$categories = $categories->load(); | |
} | |
$basename_indexes = array('news' => 0, 'guides' => 1, 'reviews' => 2, 'features' => 3); | |
$_sorted = array(4); | |
foreach($categories as $cat){ | |
if(array_key_exists($cat->basename, $basename_indexes)){ | |
$_sorted[$basename_indexes[$cat->basename]] = $cat; | |
}else{ | |
$_sorted[] = $cat; | |
} | |
} | |
return $_sorted; | |
} | |
?> | |
<? | |
$category = data::get_top_level_category($resource); | |
$cat_paths = new ResourceList(array('apple/', 'business/', 'gaming/', 'hardware/', 'microsoft/', 'open-source/', 'tech-policy/')); | |
$primary_categories = $cat_paths->load(); | |
?> | |
<div id="navigation"> | |
<ul id="primary-navigation"> | |
<li class="<?= !$category ? 'current-selection' : '' ?>"><a href="<?= $GLOBALS['site_root'] ?>">All</a></li> | |
<? foreach($primary_categories as $cat){?> | |
<li class="<?= $category && $category->id == $cat->id ? 'current-selection' : '' ?>"><a href="<?= $render->url_for($cat) ?>"><?= $cat->name ?></a></li> | |
<? } ?> | |
</ul> | |
<ul id="secondary-navigation"> | |
<? foreach(data::sort_categories($category->children) as $cat){ ?> | |
<li><a href="<?= $render->url_for($cat) ?>"><?= $cat->name ?></a></li> | |
<? } ?> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment