Hey,

I have a side navigation bar for when customers are on product or category pages but when you are on the main category page and haven't gone into any sub categories the bottom link is open like you are in that sub category. I cant work out why though. I have printed my code that makes the side navigation bar and also the function i think the problem is at. I have had this problem since the start and i cant figure it out i am in desperate need of help.

Code that make the side navigation

Code:
<?php
ob_start();

$store_categories = $this->getLeftCategories();
if ($count = count($store_categories)) {

$block_title = $this->getBlockTitle();
if ( empty($block_title) ) $block_title = 'Categories';
?>
<div class="block block-left-nav">
    <div class="block-title">
        <strong><span><?php echo $this->__($block_title) ?></span></strong>
    </div>
    <div class="block-content">
        <ul id="left-nav">
        <?php
        $i=0;
        foreach ($store_categories as $_category) {
            $class = array();
            if (!$i) {
                $class[] = 'first';
            } elseif ($i == $count) {
                $class[] = 'last';
            }
            echo $this->drawOpenCategoryItem($_category, 0, $class);
            $i++;
        } ?>
        </ul>
    </div>
</div>
<?php
} 
// if ($count = count($store_categories)) {
$mdms_blocks = Mage::registry('mdms_blocks');
if ( !$mdms_blocks ) {
    $mdms_blocks = array();
} else {
    Mage::unregister('mdms_blocks');
}
$mdms_blocks['block_left_nav'] = ob_get_clean();
Mage::register('mdms_blocks', $mdms_blocks);
This is the drawOpenCategoryItem function

Code:
public function drawOpenCategoryItem($category) {
    $html = '';
    if (!$category->getIsActive()) {
        return $html;
    }

    $html .= '<li';

    if ($this->isCategoryActive($category)) {
        $html .= ' class="active"';
    }

    $html .= '>' . "\n";
    $html .= '<a href="'.$this->getCategoryUrl($category).'">'
        . '<span>' . $this->escapeHtml($category->getName()) . '</span></a>' . "\n";

    if (in_array($category->getId(), $this->getCurrentCategoryPath())) {
        $children = $category->getChildren();
        $hasChildren = $children && $children->count();

        if ($hasChildren) {
            $htmlChildren = '';
            foreach ($children as $child) {
                $htmlChildren .= $this->drawOpenCategoryItem($child);
            }

            if (!empty($htmlChildren)) {
                $html .= '<ul>' . "\n" . $htmlChildren . '</ul>';
            }
        }
    }
    $html .= '</li>'."\n";

    return $html;
}
If i havn't explained to well and you would like a pic let me know.

View more threads in the same category: