Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Created January 26, 2012 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daltonrooney/1683831 to your computer and use it in GitHub Desktop.
Save daltonrooney/1683831 to your computer and use it in GitHub Desktop.
Custom menus for Xsilva Lightspeed
<?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