Created
May 8, 2012 19:42
-
-
Save dardub/2638754 to your computer and use it in GitHub Desktop.
nested breadcrumbs
This file contains 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
<!-- start breadcrumbs --> | |
<? if ( isset($category) && $category instanceof Shop_Category ): | |
$parent_categories = $category->get_parents(true); | |
?> | |
<ol class="breadcrumbs"> | |
<? foreach ($parent_categories as $parent_category): ?> | |
<li class="<?= $parent_category->id == $category->id ? 'last' : null ?>"> | |
<? if ($parent_category->id != $category->id): ?><a href="<?= $parent_category->page_url('/category') ?>"><? endif ?> | |
<?= h($parent_category->name) ?> | |
<? if ($parent_category->id != $category->id): ?></a><? endif ?> | |
</li> | |
<? if ( $parent_category->id != $category->id ): ?> | |
<li>→</li> | |
<? endif ?> | |
<? endforeach ?> | |
</ol> | |
<? elseif (isset($product)): | |
$product_categories = $product->category_list->objectArray; | |
function sort_product_categories($a, $b, $c='front_end_sort_order') | |
{ | |
if ($a->$c == $b->$c) return 0; | |
return ($a->$c < $b->$c) ? 1 : -1; | |
} | |
usort ($product_categories, 'sort_product_categories'); | |
$parent_categories = $product_categories[0]->get_parents(true); | |
?> | |
<ol class="breadcrumbs"> | |
<? foreach ($parent_categories as $parent_category): ?> | |
<li> | |
<a href="<?= $parent_category->page_url('/category') ?>"><?= h($parent_category->name) ?></a> | |
</li> | |
<li>→</li> | |
<? endforeach ?> | |
<li class="last"><?= h($product->name) ?></li> | |
</ol> | |
<? elseif( isset($manufacturer) && $manufacturer): ?> | |
<ol class="breadcrumbs"> | |
<li><a href="<?= root_url('/manufacturer') ?>">Manufacturers</a></li> | |
<li>→</li> | |
<li><? if(isset($category_id)): ?><a href="<?= root_url('/manufacturer/'.$manufacturer->url_name) ?>"><? endif ?> | |
<?= $manufacturer->name ?> | |
<? if(isset($category_id)): ?></a><? endif ?> | |
</li> | |
<? if(isset($category_id)): ?> | |
<li>→</li> | |
<? $category = Shop_Category::create()->find($category_id); ?> | |
<li><?= $category->name ?></li> | |
<? endif ?> | |
</ol> | |
<? endif ?> | |
<!-- end breadcrumbs --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment