Created
January 26, 2012 17:08
-
-
Save daltonrooney/1683831 to your computer and use it in GitHub Desktop.
Custom menus for Xsilva Lightspeed
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
<?php function print_childs($categ, $catid){ | |
$childs = $categ->categ_childs; | |
if( !$childs || ( count( $childs ) == 0 ) ){ | |
return; | |
} | |
foreach($childs as $category){ | |
if(!$category->HasChildOrProduct()) | |
continue; | |
?> | |
<li><a <?php if ( $catid == $category->Rowid ) { echo 'class="selected" ';} ?>href="<?= $category->Link; ?>"><?= $category->Name; ?><?php print_childs($category); ?></a></li> | |
<?php }; | |
} // end function ?> | |
<div id="nav_products"> | |
<ul id="menu1" class="menu collapsible"> | |
<?php foreach($this->menu_categories as $category):?> | |
<?php if ( empty( $_GET['product'] ) && empty( $_GET['xlspg'] ) && empty( $_GET['search'] ) ) { // if we're on a non-product page | |
$catid = $this->category->Rowid; ?> | |
<?php } elseif ( !empty( $_GET['product'] ) ) { // on the product pages, access the category ID through the URL | |
$catid = $_GET['c']; | |
} else { | |
$catid = 0; | |
}?> | |
<?php if ( $catid == $category->Rowid ) { $selected = true; } ?> | |
<li><a href="#"><?= $category->Name; ?></a> | |
<ul> | |
<li><a class="viewall <?php if ( $selected ) {echo " selected";}?>" href="<?= $category->Link; ?>">All <?= $category->Name; ?></a></li> | |
<?php print_childs($category, $catid); ?> | |
</ul> | |
</li> | |
<?php $selected = false;?> | |
<?php endforeach; ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment