Bottom Category on left navigation is always openif no child categories then return categories of same levelExclude a specific categoryTop Menu cache problemCreate categories through installerScript to hide empty categories works but not with products without stockAdd category id to product item classLooking to create a Category Attribute that will allow me to change the style of my dropdown navigationMagento 2 get category count getChildCategories()Call to undefined method Collection::getData()Pagination count issue in custom varient collection

Email Account under attack (really) - anything I can do?

TGV timetables / schedules?

What does "Puller Prush Person" mean?

Is it legal for company to use my work email to pretend I still work there?

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

Is it important to consider tone, melody, and musical form while writing a song?

Minkowski space

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Dragon forelimb placement

How to format long polynomial?

Can a Warlock become Neutral Good?

Why don't electron-positron collisions release infinite energy?

How could an uplifted falcon's brain work?

Why can't I see bouncing of a switch on an oscilloscope?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

What is the word for reserving something for yourself before others do?

can i play a electric guitar through a bass amp?

Fencing style for blades that can attack from a distance

Why doesn't H₄O²⁺ exist?

Why dont electromagnetic waves interact with each other?

How can bays and straits be determined in a procedurally generated map?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Why not use SQL instead of GraphQL?

How does strength of boric acid solution increase in presence of salicylic acid?



Bottom Category on left navigation is always open


if no child categories then return categories of same levelExclude a specific categoryTop Menu cache problemCreate categories through installerScript to hide empty categories works but not with products without stockAdd category id to product item classLooking to create a Category Attribute that will allow me to change the style of my dropdown navigationMagento 2 get category count getChildCategories()Call to undefined method Collection::getData()Pagination count issue in custom varient collection






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have a problem on my product categories page the navigation that we have going down the left side displays all the categories we need it to and also it bold a subcategory when you are on it, However when you are not on any sub categories and you are on the main categories page The bottom category is always in bold even when you are not on it.



This is my code which creates the navigation (this is a .phtml file)



<?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);


I assume that what opens the categories is the drawOpenCategoryItem function



This is the code in the navigation.php which has that function in it but i cant see anything wrong.



<?php
/**
* @version 1.0 12.0.2012
* @author
* @copyright Copyright (C) 2010 - 2012
*/

class our_ThemeSettings_Block_Navigation extends Mage_Catalog_Block_Navigation


/**
* columns html
*
* @var array
*/
protected $_columnHtml;

/*
* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected $_leftCategories;

/**
* top level parent category for current category
*
* @var int
*/
protected $_parent;

protected function _construct()

$path = $this->getCurrentCategoryPath();
$parent = $path[count($path)-2];
if (!$parent)
$parent = Mage::app()->getStore()->getRootCategoryId();

$this->_parent = $parent;



/**
* render category html
*
* @param Mage_Catalog_Model_Category $category
* @param integer $level
* @param array $levelClass
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0, array $levelClass = null)

$html = array();

if (!$category->getIsActive()) return '';

if (!isset($levelClass)) $levelClass = array();
$combineClasses = array();

$combineClasses[] = 'level' . $level;
if ($this->_isCurrentCategory($category))
$combineClasses[] = 'active';
else
$combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';

$levelClass[] = implode('-', $combineClasses);
$levelClass = array_merge($levelClass, $combineClasses);
$levelClass[] = $this->_getClassNameFromCategoryName($category);

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

if ( in_array($category->getId(), $this->getCurrentCategoryPath()) )
$children = $this->_getLeftCategoryCollection()
->addIdFilter($category->getChildren());

$hasChildren = $children && ($childrenCount = count($children));
if ($hasChildren)
$htmlChildren = '';

foreach ($children as $i => $child)

$class = array();
if ($childrenCount == 1)
$class[] = 'only';

else

if (!$i) $class[] = 'first';
if ($i == $childrenCount - 1) $class[] = 'last';

$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1, $class);


if (!empty($htmlChildren))
$levelClass[] = 'open';

$html[2] = '<ul>' . "n"
. $htmlChildren . "n"
. '</ul>';




$html[0] = sprintf('<li class="%s">', implode(" ", $levelClass)) . "n";
$html[3] = "n" . '</li>' . "n";

ksort($html);
return implode('', $html);


/**
* Convert the category name into a string that can be used as a css class
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
protected function _getClassNameFromCategoryName($category)

$name = $category->getName();
$name = preg_replace('/-2,/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name)));
while ($name && $name0 == '-') $name = substr($name, 1);
while ($name && substr($name, -1) == '-') $name = substr($name, 0, -1);
return $name;


/**
* Check if the current category matches the passed in category
*
* @param Mage_Catalog_Model_Category $category
* @return bool
*/
protected function _isCurrentCategory($category)

return ($cat = $this->getCurrentCategory()) && $cat->getId() == $category->getId();


/**
* return top level category name
*
* @return string
*/
public function getBlockTitle()
if ( $this->_parent == Mage::app()->getStore()->getRootCategoryId() )
return '';
else
return Mage::getModel('catalog/category')->load($this->_parent)->getName();



/**
* Get sibling catagories
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
public function getLeftCategories()


/**
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected function _getLeftCategoryCollection()

$collection = Mage::getResourceModel('catalog/category_collection');
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1)
->setOrder('position', 'ASC')
->joinUrlRewrite();
return $collection;


/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
else
$children = $category->getChildren();
$childrenCount = $children->count();

$hasChildren = ($children && $childrenCount);

// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;


$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);

// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category))
$classes[] = 'active';

$linkClass = '';
if ($isOutermost && $outermostItemClass)
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';

if ($isFirst)
$classes[] = 'first';

if ($isLast)
$classes[] = 'last';

if ($hasActiveChildren)
$classes[] = 'parent';


// prepare list item attributes
$attributes = array();
if (count($classes) > 0)
$attributes['class'] = implode(' ', $classes);

if ($hasActiveChildren && !$noEventAttributes)
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';


// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue)
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';

$htmlLi .= '>';
$html[] = $htmlLi;

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

$columnItemsNum = array();
if ($level == 0 && $activeChildrenCount)
$items_per_column = Mage::getStoreConfig('theme/navigation/column_items');
$columns = ceil($activeChildrenCount / $items_per_column);
$columnItemsNum = array_fill(0, $columns, $items_per_column);
$this->_columnHtml = array();


// render children
$htmlChildren = '';
$j = 0; //child index
$i = 0; //column index
$itemsCount = $activeChildrenCount;
if (isset($columnItemsNum[$i]))
$itemsCount = $columnItemsNum[$i];

foreach ($activeChildren as $child)

if ($level == 0)
$isLast = (($j + 1) == $itemsCount else
$isLast = ($j == $activeChildrenCount - 1);


$childHtml = $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
$isLast,
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
if ($level == 0)
$this->_columnHtml[] = $childHtml;
else
$htmlChildren .= $childHtml;

$j++;


if ($level == 0 && $this->_columnHtml)
$i = 0;
foreach ($columnItemsNum as $columnNum)
$chunk = array_slice($this->_columnHtml, $i, $columnNum);
$i += $columnNum;
$htmlChildren .= '<li ' . (count($this->_columnHtml) == $i ? 'class="last"' : '') . '><ol>';
foreach ($chunk as $item)
$htmlChildren .= $item;

$htmlChildren .= '</ol></li>';



if (!empty($htmlChildren))
if ($childrenWrapClass)
$html[] = '<div class="' . $childrenWrapClass . '">';

$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass)
$html[] = '</div>';



$html[] = '</li>';

$html = implode("n", $html);
return $html;



/**
* Render categories menu in selectbox element
*
* @param int Level number for list item class to start from
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @return string
*/
public function renderCategoriesSelectOptions($level = 0, $outermostItemClass = '', $childrenWrapClass = '')

$activeCategories = array();
foreach ($this->getStoreCategories() as $child)
if ($child->getIsActive())
$activeCategories[] = $child;


$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);

if (!$hasActiveCategoriesCount)
return '';


$html = '<option value="">' . $this->__('- Please select category -') . '</option>';
$j = 0;
foreach ($activeCategories as $category)
$html .= $this->_renderCategorySelectOption(
$category,
$level,
($j == $activeCategoriesCount - 1),
($j == 0),
true,
$outermostItemClass,
$childrenWrapClass,
true
);
$j++;


return $html;



/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategorySelectOption($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
else
$children = $category->getChildren();


// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;



$active = '';
if ($this->isCategoryActive($category))
$active = 'selected="selected"';

// assemble list item with attributes
$html[] = '<option value="'.$this->getCategoryUrl($category).'" '.$active.'>' . str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$level) . $this->escapeHtml($category->getName()) . '</option>';

// render children
$htmlChildren = '';
foreach ($activeChildren as $child)
$childHtml = $this->_renderCategorySelectOption(
$child,
($level + 1),
0,
0,
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$htmlChildren .= $childHtml;


if (!empty($htmlChildren))
$html[] = $htmlChildren;


$html = implode("n", $html);
return $html;






If you can see anything which maybe causing this problem could you let me know please as i am lost with this problem.



Thank you










share|improve this question
















bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • inspect this subcategory, see if there is any supernumerary class added to the element.

    – Julien Lachal
    Oct 14 '14 at 12:02











  • The class change from inactive to active on the bottom category, same as when you are actually in the category

    – Adam Allen
    Oct 14 '14 at 12:19











  • Can you add either a image or add a url

    – Renon Stewart
    Oct 14 '14 at 14:00











  • @R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

    – Adam Allen
    Oct 14 '14 at 14:01












  • Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

    – Amasty
    Oct 14 '14 at 14:21

















3















I have a problem on my product categories page the navigation that we have going down the left side displays all the categories we need it to and also it bold a subcategory when you are on it, However when you are not on any sub categories and you are on the main categories page The bottom category is always in bold even when you are not on it.



This is my code which creates the navigation (this is a .phtml file)



<?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);


I assume that what opens the categories is the drawOpenCategoryItem function



This is the code in the navigation.php which has that function in it but i cant see anything wrong.



<?php
/**
* @version 1.0 12.0.2012
* @author
* @copyright Copyright (C) 2010 - 2012
*/

class our_ThemeSettings_Block_Navigation extends Mage_Catalog_Block_Navigation


/**
* columns html
*
* @var array
*/
protected $_columnHtml;

/*
* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected $_leftCategories;

/**
* top level parent category for current category
*
* @var int
*/
protected $_parent;

protected function _construct()

$path = $this->getCurrentCategoryPath();
$parent = $path[count($path)-2];
if (!$parent)
$parent = Mage::app()->getStore()->getRootCategoryId();

$this->_parent = $parent;



/**
* render category html
*
* @param Mage_Catalog_Model_Category $category
* @param integer $level
* @param array $levelClass
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0, array $levelClass = null)

$html = array();

if (!$category->getIsActive()) return '';

if (!isset($levelClass)) $levelClass = array();
$combineClasses = array();

$combineClasses[] = 'level' . $level;
if ($this->_isCurrentCategory($category))
$combineClasses[] = 'active';
else
$combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';

$levelClass[] = implode('-', $combineClasses);
$levelClass = array_merge($levelClass, $combineClasses);
$levelClass[] = $this->_getClassNameFromCategoryName($category);

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

if ( in_array($category->getId(), $this->getCurrentCategoryPath()) )
$children = $this->_getLeftCategoryCollection()
->addIdFilter($category->getChildren());

$hasChildren = $children && ($childrenCount = count($children));
if ($hasChildren)
$htmlChildren = '';

foreach ($children as $i => $child)

$class = array();
if ($childrenCount == 1)
$class[] = 'only';

else

if (!$i) $class[] = 'first';
if ($i == $childrenCount - 1) $class[] = 'last';

$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1, $class);


if (!empty($htmlChildren))
$levelClass[] = 'open';

$html[2] = '<ul>' . "n"
. $htmlChildren . "n"
. '</ul>';




$html[0] = sprintf('<li class="%s">', implode(" ", $levelClass)) . "n";
$html[3] = "n" . '</li>' . "n";

ksort($html);
return implode('', $html);


/**
* Convert the category name into a string that can be used as a css class
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
protected function _getClassNameFromCategoryName($category)

$name = $category->getName();
$name = preg_replace('/-2,/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name)));
while ($name && $name0 == '-') $name = substr($name, 1);
while ($name && substr($name, -1) == '-') $name = substr($name, 0, -1);
return $name;


/**
* Check if the current category matches the passed in category
*
* @param Mage_Catalog_Model_Category $category
* @return bool
*/
protected function _isCurrentCategory($category)

return ($cat = $this->getCurrentCategory()) && $cat->getId() == $category->getId();


/**
* return top level category name
*
* @return string
*/
public function getBlockTitle()
if ( $this->_parent == Mage::app()->getStore()->getRootCategoryId() )
return '';
else
return Mage::getModel('catalog/category')->load($this->_parent)->getName();



/**
* Get sibling catagories
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
public function getLeftCategories()


/**
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected function _getLeftCategoryCollection()

$collection = Mage::getResourceModel('catalog/category_collection');
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1)
->setOrder('position', 'ASC')
->joinUrlRewrite();
return $collection;


/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
else
$children = $category->getChildren();
$childrenCount = $children->count();

$hasChildren = ($children && $childrenCount);

// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;


$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);

// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category))
$classes[] = 'active';

$linkClass = '';
if ($isOutermost && $outermostItemClass)
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';

if ($isFirst)
$classes[] = 'first';

if ($isLast)
$classes[] = 'last';

if ($hasActiveChildren)
$classes[] = 'parent';


// prepare list item attributes
$attributes = array();
if (count($classes) > 0)
$attributes['class'] = implode(' ', $classes);

if ($hasActiveChildren && !$noEventAttributes)
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';


// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue)
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';

$htmlLi .= '>';
$html[] = $htmlLi;

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

$columnItemsNum = array();
if ($level == 0 && $activeChildrenCount)
$items_per_column = Mage::getStoreConfig('theme/navigation/column_items');
$columns = ceil($activeChildrenCount / $items_per_column);
$columnItemsNum = array_fill(0, $columns, $items_per_column);
$this->_columnHtml = array();


// render children
$htmlChildren = '';
$j = 0; //child index
$i = 0; //column index
$itemsCount = $activeChildrenCount;
if (isset($columnItemsNum[$i]))
$itemsCount = $columnItemsNum[$i];

foreach ($activeChildren as $child)

if ($level == 0)
$isLast = (($j + 1) == $itemsCount else
$isLast = ($j == $activeChildrenCount - 1);


$childHtml = $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
$isLast,
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
if ($level == 0)
$this->_columnHtml[] = $childHtml;
else
$htmlChildren .= $childHtml;

$j++;


if ($level == 0 && $this->_columnHtml)
$i = 0;
foreach ($columnItemsNum as $columnNum)
$chunk = array_slice($this->_columnHtml, $i, $columnNum);
$i += $columnNum;
$htmlChildren .= '<li ' . (count($this->_columnHtml) == $i ? 'class="last"' : '') . '><ol>';
foreach ($chunk as $item)
$htmlChildren .= $item;

$htmlChildren .= '</ol></li>';



if (!empty($htmlChildren))
if ($childrenWrapClass)
$html[] = '<div class="' . $childrenWrapClass . '">';

$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass)
$html[] = '</div>';



$html[] = '</li>';

$html = implode("n", $html);
return $html;



/**
* Render categories menu in selectbox element
*
* @param int Level number for list item class to start from
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @return string
*/
public function renderCategoriesSelectOptions($level = 0, $outermostItemClass = '', $childrenWrapClass = '')

$activeCategories = array();
foreach ($this->getStoreCategories() as $child)
if ($child->getIsActive())
$activeCategories[] = $child;


$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);

if (!$hasActiveCategoriesCount)
return '';


$html = '<option value="">' . $this->__('- Please select category -') . '</option>';
$j = 0;
foreach ($activeCategories as $category)
$html .= $this->_renderCategorySelectOption(
$category,
$level,
($j == $activeCategoriesCount - 1),
($j == 0),
true,
$outermostItemClass,
$childrenWrapClass,
true
);
$j++;


return $html;



/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategorySelectOption($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
else
$children = $category->getChildren();


// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;



$active = '';
if ($this->isCategoryActive($category))
$active = 'selected="selected"';

// assemble list item with attributes
$html[] = '<option value="'.$this->getCategoryUrl($category).'" '.$active.'>' . str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$level) . $this->escapeHtml($category->getName()) . '</option>';

// render children
$htmlChildren = '';
foreach ($activeChildren as $child)
$childHtml = $this->_renderCategorySelectOption(
$child,
($level + 1),
0,
0,
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$htmlChildren .= $childHtml;


if (!empty($htmlChildren))
$html[] = $htmlChildren;


$html = implode("n", $html);
return $html;






If you can see anything which maybe causing this problem could you let me know please as i am lost with this problem.



Thank you










share|improve this question
















bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • inspect this subcategory, see if there is any supernumerary class added to the element.

    – Julien Lachal
    Oct 14 '14 at 12:02











  • The class change from inactive to active on the bottom category, same as when you are actually in the category

    – Adam Allen
    Oct 14 '14 at 12:19











  • Can you add either a image or add a url

    – Renon Stewart
    Oct 14 '14 at 14:00











  • @R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

    – Adam Allen
    Oct 14 '14 at 14:01












  • Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

    – Amasty
    Oct 14 '14 at 14:21













3












3








3








I have a problem on my product categories page the navigation that we have going down the left side displays all the categories we need it to and also it bold a subcategory when you are on it, However when you are not on any sub categories and you are on the main categories page The bottom category is always in bold even when you are not on it.



This is my code which creates the navigation (this is a .phtml file)



<?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);


I assume that what opens the categories is the drawOpenCategoryItem function



This is the code in the navigation.php which has that function in it but i cant see anything wrong.



<?php
/**
* @version 1.0 12.0.2012
* @author
* @copyright Copyright (C) 2010 - 2012
*/

class our_ThemeSettings_Block_Navigation extends Mage_Catalog_Block_Navigation


/**
* columns html
*
* @var array
*/
protected $_columnHtml;

/*
* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected $_leftCategories;

/**
* top level parent category for current category
*
* @var int
*/
protected $_parent;

protected function _construct()

$path = $this->getCurrentCategoryPath();
$parent = $path[count($path)-2];
if (!$parent)
$parent = Mage::app()->getStore()->getRootCategoryId();

$this->_parent = $parent;



/**
* render category html
*
* @param Mage_Catalog_Model_Category $category
* @param integer $level
* @param array $levelClass
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0, array $levelClass = null)

$html = array();

if (!$category->getIsActive()) return '';

if (!isset($levelClass)) $levelClass = array();
$combineClasses = array();

$combineClasses[] = 'level' . $level;
if ($this->_isCurrentCategory($category))
$combineClasses[] = 'active';
else
$combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';

$levelClass[] = implode('-', $combineClasses);
$levelClass = array_merge($levelClass, $combineClasses);
$levelClass[] = $this->_getClassNameFromCategoryName($category);

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

if ( in_array($category->getId(), $this->getCurrentCategoryPath()) )
$children = $this->_getLeftCategoryCollection()
->addIdFilter($category->getChildren());

$hasChildren = $children && ($childrenCount = count($children));
if ($hasChildren)
$htmlChildren = '';

foreach ($children as $i => $child)

$class = array();
if ($childrenCount == 1)
$class[] = 'only';

else

if (!$i) $class[] = 'first';
if ($i == $childrenCount - 1) $class[] = 'last';

$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1, $class);


if (!empty($htmlChildren))
$levelClass[] = 'open';

$html[2] = '<ul>' . "n"
. $htmlChildren . "n"
. '</ul>';




$html[0] = sprintf('<li class="%s">', implode(" ", $levelClass)) . "n";
$html[3] = "n" . '</li>' . "n";

ksort($html);
return implode('', $html);


/**
* Convert the category name into a string that can be used as a css class
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
protected function _getClassNameFromCategoryName($category)

$name = $category->getName();
$name = preg_replace('/-2,/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name)));
while ($name && $name0 == '-') $name = substr($name, 1);
while ($name && substr($name, -1) == '-') $name = substr($name, 0, -1);
return $name;


/**
* Check if the current category matches the passed in category
*
* @param Mage_Catalog_Model_Category $category
* @return bool
*/
protected function _isCurrentCategory($category)

return ($cat = $this->getCurrentCategory()) && $cat->getId() == $category->getId();


/**
* return top level category name
*
* @return string
*/
public function getBlockTitle()
if ( $this->_parent == Mage::app()->getStore()->getRootCategoryId() )
return '';
else
return Mage::getModel('catalog/category')->load($this->_parent)->getName();



/**
* Get sibling catagories
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
public function getLeftCategories()


/**
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected function _getLeftCategoryCollection()

$collection = Mage::getResourceModel('catalog/category_collection');
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1)
->setOrder('position', 'ASC')
->joinUrlRewrite();
return $collection;


/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
else
$children = $category->getChildren();
$childrenCount = $children->count();

$hasChildren = ($children && $childrenCount);

// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;


$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);

// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category))
$classes[] = 'active';

$linkClass = '';
if ($isOutermost && $outermostItemClass)
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';

if ($isFirst)
$classes[] = 'first';

if ($isLast)
$classes[] = 'last';

if ($hasActiveChildren)
$classes[] = 'parent';


// prepare list item attributes
$attributes = array();
if (count($classes) > 0)
$attributes['class'] = implode(' ', $classes);

if ($hasActiveChildren && !$noEventAttributes)
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';


// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue)
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';

$htmlLi .= '>';
$html[] = $htmlLi;

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

$columnItemsNum = array();
if ($level == 0 && $activeChildrenCount)
$items_per_column = Mage::getStoreConfig('theme/navigation/column_items');
$columns = ceil($activeChildrenCount / $items_per_column);
$columnItemsNum = array_fill(0, $columns, $items_per_column);
$this->_columnHtml = array();


// render children
$htmlChildren = '';
$j = 0; //child index
$i = 0; //column index
$itemsCount = $activeChildrenCount;
if (isset($columnItemsNum[$i]))
$itemsCount = $columnItemsNum[$i];

foreach ($activeChildren as $child)

if ($level == 0)
$isLast = (($j + 1) == $itemsCount else
$isLast = ($j == $activeChildrenCount - 1);


$childHtml = $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
$isLast,
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
if ($level == 0)
$this->_columnHtml[] = $childHtml;
else
$htmlChildren .= $childHtml;

$j++;


if ($level == 0 && $this->_columnHtml)
$i = 0;
foreach ($columnItemsNum as $columnNum)
$chunk = array_slice($this->_columnHtml, $i, $columnNum);
$i += $columnNum;
$htmlChildren .= '<li ' . (count($this->_columnHtml) == $i ? 'class="last"' : '') . '><ol>';
foreach ($chunk as $item)
$htmlChildren .= $item;

$htmlChildren .= '</ol></li>';



if (!empty($htmlChildren))
if ($childrenWrapClass)
$html[] = '<div class="' . $childrenWrapClass . '">';

$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass)
$html[] = '</div>';



$html[] = '</li>';

$html = implode("n", $html);
return $html;



/**
* Render categories menu in selectbox element
*
* @param int Level number for list item class to start from
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @return string
*/
public function renderCategoriesSelectOptions($level = 0, $outermostItemClass = '', $childrenWrapClass = '')

$activeCategories = array();
foreach ($this->getStoreCategories() as $child)
if ($child->getIsActive())
$activeCategories[] = $child;


$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);

if (!$hasActiveCategoriesCount)
return '';


$html = '<option value="">' . $this->__('- Please select category -') . '</option>';
$j = 0;
foreach ($activeCategories as $category)
$html .= $this->_renderCategorySelectOption(
$category,
$level,
($j == $activeCategoriesCount - 1),
($j == 0),
true,
$outermostItemClass,
$childrenWrapClass,
true
);
$j++;


return $html;



/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategorySelectOption($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
else
$children = $category->getChildren();


// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;



$active = '';
if ($this->isCategoryActive($category))
$active = 'selected="selected"';

// assemble list item with attributes
$html[] = '<option value="'.$this->getCategoryUrl($category).'" '.$active.'>' . str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$level) . $this->escapeHtml($category->getName()) . '</option>';

// render children
$htmlChildren = '';
foreach ($activeChildren as $child)
$childHtml = $this->_renderCategorySelectOption(
$child,
($level + 1),
0,
0,
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$htmlChildren .= $childHtml;


if (!empty($htmlChildren))
$html[] = $htmlChildren;


$html = implode("n", $html);
return $html;






If you can see anything which maybe causing this problem could you let me know please as i am lost with this problem.



Thank you










share|improve this question
















I have a problem on my product categories page the navigation that we have going down the left side displays all the categories we need it to and also it bold a subcategory when you are on it, However when you are not on any sub categories and you are on the main categories page The bottom category is always in bold even when you are not on it.



This is my code which creates the navigation (this is a .phtml file)



<?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);


I assume that what opens the categories is the drawOpenCategoryItem function



This is the code in the navigation.php which has that function in it but i cant see anything wrong.



<?php
/**
* @version 1.0 12.0.2012
* @author
* @copyright Copyright (C) 2010 - 2012
*/

class our_ThemeSettings_Block_Navigation extends Mage_Catalog_Block_Navigation


/**
* columns html
*
* @var array
*/
protected $_columnHtml;

/*
* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected $_leftCategories;

/**
* top level parent category for current category
*
* @var int
*/
protected $_parent;

protected function _construct()

$path = $this->getCurrentCategoryPath();
$parent = $path[count($path)-2];
if (!$parent)
$parent = Mage::app()->getStore()->getRootCategoryId();

$this->_parent = $parent;



/**
* render category html
*
* @param Mage_Catalog_Model_Category $category
* @param integer $level
* @param array $levelClass
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0, array $levelClass = null)

$html = array();

if (!$category->getIsActive()) return '';

if (!isset($levelClass)) $levelClass = array();
$combineClasses = array();

$combineClasses[] = 'level' . $level;
if ($this->_isCurrentCategory($category))
$combineClasses[] = 'active';
else
$combineClasses[] = $this->isCategoryActive($category) ? 'parent' : 'inactive';

$levelClass[] = implode('-', $combineClasses);
$levelClass = array_merge($levelClass, $combineClasses);
$levelClass[] = $this->_getClassNameFromCategoryName($category);

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

if ( in_array($category->getId(), $this->getCurrentCategoryPath()) )
$children = $this->_getLeftCategoryCollection()
->addIdFilter($category->getChildren());

$hasChildren = $children && ($childrenCount = count($children));
if ($hasChildren)
$htmlChildren = '';

foreach ($children as $i => $child)

$class = array();
if ($childrenCount == 1)
$class[] = 'only';

else

if (!$i) $class[] = 'first';
if ($i == $childrenCount - 1) $class[] = 'last';

$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1, $class);


if (!empty($htmlChildren))
$levelClass[] = 'open';

$html[2] = '<ul>' . "n"
. $htmlChildren . "n"
. '</ul>';




$html[0] = sprintf('<li class="%s">', implode(" ", $levelClass)) . "n";
$html[3] = "n" . '</li>' . "n";

ksort($html);
return implode('', $html);


/**
* Convert the category name into a string that can be used as a css class
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
protected function _getClassNameFromCategoryName($category)

$name = $category->getName();
$name = preg_replace('/-2,/', '-', preg_replace('/[^a-z-]/', '-', strtolower($name)));
while ($name && $name0 == '-') $name = substr($name, 1);
while ($name && substr($name, -1) == '-') $name = substr($name, 0, -1);
return $name;


/**
* Check if the current category matches the passed in category
*
* @param Mage_Catalog_Model_Category $category
* @return bool
*/
protected function _isCurrentCategory($category)

return ($cat = $this->getCurrentCategory()) && $cat->getId() == $category->getId();


/**
* return top level category name
*
* @return string
*/
public function getBlockTitle()
if ( $this->_parent == Mage::app()->getStore()->getRootCategoryId() )
return '';
else
return Mage::getModel('catalog/category')->load($this->_parent)->getName();



/**
* Get sibling catagories
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
public function getLeftCategories()


/**
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
*/
protected function _getLeftCategoryCollection()

$collection = Mage::getResourceModel('catalog/category_collection');
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1)
->setOrder('position', 'ASC')
->joinUrlRewrite();
return $collection;


/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
else
$children = $category->getChildren();
$childrenCount = $children->count();

$hasChildren = ($children && $childrenCount);

// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;


$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);

// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category))
$classes[] = 'active';

$linkClass = '';
if ($isOutermost && $outermostItemClass)
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';

if ($isFirst)
$classes[] = 'first';

if ($isLast)
$classes[] = 'last';

if ($hasActiveChildren)
$classes[] = 'parent';


// prepare list item attributes
$attributes = array();
if (count($classes) > 0)
$attributes['class'] = implode(' ', $classes);

if ($hasActiveChildren && !$noEventAttributes)
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';


// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue)
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';

$htmlLi .= '>';
$html[] = $htmlLi;

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

$columnItemsNum = array();
if ($level == 0 && $activeChildrenCount)
$items_per_column = Mage::getStoreConfig('theme/navigation/column_items');
$columns = ceil($activeChildrenCount / $items_per_column);
$columnItemsNum = array_fill(0, $columns, $items_per_column);
$this->_columnHtml = array();


// render children
$htmlChildren = '';
$j = 0; //child index
$i = 0; //column index
$itemsCount = $activeChildrenCount;
if (isset($columnItemsNum[$i]))
$itemsCount = $columnItemsNum[$i];

foreach ($activeChildren as $child)

if ($level == 0)
$isLast = (($j + 1) == $itemsCount else
$isLast = ($j == $activeChildrenCount - 1);


$childHtml = $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
$isLast,
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
if ($level == 0)
$this->_columnHtml[] = $childHtml;
else
$htmlChildren .= $childHtml;

$j++;


if ($level == 0 && $this->_columnHtml)
$i = 0;
foreach ($columnItemsNum as $columnNum)
$chunk = array_slice($this->_columnHtml, $i, $columnNum);
$i += $columnNum;
$htmlChildren .= '<li ' . (count($this->_columnHtml) == $i ? 'class="last"' : '') . '><ol>';
foreach ($chunk as $item)
$htmlChildren .= $item;

$htmlChildren .= '</ol></li>';



if (!empty($htmlChildren))
if ($childrenWrapClass)
$html[] = '<div class="' . $childrenWrapClass . '">';

$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass)
$html[] = '</div>';



$html[] = '</li>';

$html = implode("n", $html);
return $html;



/**
* Render categories menu in selectbox element
*
* @param int Level number for list item class to start from
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @return string
*/
public function renderCategoriesSelectOptions($level = 0, $outermostItemClass = '', $childrenWrapClass = '')

$activeCategories = array();
foreach ($this->getStoreCategories() as $child)
if ($child->getIsActive())
$activeCategories[] = $child;


$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);

if (!$hasActiveCategoriesCount)
return '';


$html = '<option value="">' . $this->__('- Please select category -') . '</option>';
$j = 0;
foreach ($activeCategories as $category)
$html .= $this->_renderCategorySelectOption(
$category,
$level,
($j == $activeCategoriesCount - 1),
($j == 0),
true,
$outermostItemClass,
$childrenWrapClass,
true
);
$j++;


return $html;



/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategorySelectOption($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

if (!$category->getIsActive())
return '';

$html = array();

// get all children
if (Mage::helper('catalog/category_flat')->isEnabled())
$children = (array)$category->getChildrenNodes();
else
$children = $category->getChildren();


// select active children
$activeChildren = array();
foreach ($children as $child)
if ($child->getIsActive())
$activeChildren[] = $child;



$active = '';
if ($this->isCategoryActive($category))
$active = 'selected="selected"';

// assemble list item with attributes
$html[] = '<option value="'.$this->getCategoryUrl($category).'" '.$active.'>' . str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$level) . $this->escapeHtml($category->getName()) . '</option>';

// render children
$htmlChildren = '';
foreach ($activeChildren as $child)
$childHtml = $this->_renderCategorySelectOption(
$child,
($level + 1),
0,
0,
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$htmlChildren .= $childHtml;


if (!empty($htmlChildren))
$html[] = $htmlChildren;


$html = implode("n", $html);
return $html;






If you can see anything which maybe causing this problem could you let me know please as i am lost with this problem.



Thank you







magento-1.9 category navigation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 14 '14 at 14:33







Adam Allen

















asked Oct 1 '14 at 14:53









Adam AllenAdam Allen

1,30062861




1,30062861





bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • inspect this subcategory, see if there is any supernumerary class added to the element.

    – Julien Lachal
    Oct 14 '14 at 12:02











  • The class change from inactive to active on the bottom category, same as when you are actually in the category

    – Adam Allen
    Oct 14 '14 at 12:19











  • Can you add either a image or add a url

    – Renon Stewart
    Oct 14 '14 at 14:00











  • @R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

    – Adam Allen
    Oct 14 '14 at 14:01












  • Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

    – Amasty
    Oct 14 '14 at 14:21

















  • inspect this subcategory, see if there is any supernumerary class added to the element.

    – Julien Lachal
    Oct 14 '14 at 12:02











  • The class change from inactive to active on the bottom category, same as when you are actually in the category

    – Adam Allen
    Oct 14 '14 at 12:19











  • Can you add either a image or add a url

    – Renon Stewart
    Oct 14 '14 at 14:00











  • @R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

    – Adam Allen
    Oct 14 '14 at 14:01












  • Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

    – Amasty
    Oct 14 '14 at 14:21
















inspect this subcategory, see if there is any supernumerary class added to the element.

– Julien Lachal
Oct 14 '14 at 12:02





inspect this subcategory, see if there is any supernumerary class added to the element.

– Julien Lachal
Oct 14 '14 at 12:02













The class change from inactive to active on the bottom category, same as when you are actually in the category

– Adam Allen
Oct 14 '14 at 12:19





The class change from inactive to active on the bottom category, same as when you are actually in the category

– Adam Allen
Oct 14 '14 at 12:19













Can you add either a image or add a url

– Renon Stewart
Oct 14 '14 at 14:00





Can you add either a image or add a url

– Renon Stewart
Oct 14 '14 at 14:00













@R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

– Adam Allen
Oct 14 '14 at 14:01






@R.S what an screen shot of the problem? cant give out URL because the site isnt live yet and is password protected

– Adam Allen
Oct 14 '14 at 14:01














Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

– Amasty
Oct 14 '14 at 14:21





Probably the function _isCurrentCategory gets wrong category $cat = $this->getCurrentCategory(); from the registry? What does this code return?

– Amasty
Oct 14 '14 at 14:21










2 Answers
2






active

oldest

votes


















0














This could be a CSS related issue, please try to find the exact CSS being used for that block and try to see if any Bold font design has been written over there!






share|improve this answer























  • There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

    – Adam Allen
    Oct 17 '14 at 10:32











  • The return in _isCurrentCategory($category), is it giving required output? place a log to check

    – Rahul Kumar Das
    Oct 17 '14 at 10:36











  • What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

    – Adam Allen
    Oct 17 '14 at 10:39











  • From frontend, could you check that which css property is making the bottom category BOLD?

    – Rahul Kumar Das
    Oct 17 '14 at 10:43











  • .col-left .block-left-nav li.active > a font-weight: bold;

    – Adam Allen
    Oct 17 '14 at 10:45


















0














Maybe you're just getting this active class through some JavaScript code on frontend? I would start from checking all JavaScript related to the menu.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f37696%2fbottom-category-on-left-navigation-is-always-open%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This could be a CSS related issue, please try to find the exact CSS being used for that block and try to see if any Bold font design has been written over there!






    share|improve this answer























    • There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

      – Adam Allen
      Oct 17 '14 at 10:32











    • The return in _isCurrentCategory($category), is it giving required output? place a log to check

      – Rahul Kumar Das
      Oct 17 '14 at 10:36











    • What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

      – Adam Allen
      Oct 17 '14 at 10:39











    • From frontend, could you check that which css property is making the bottom category BOLD?

      – Rahul Kumar Das
      Oct 17 '14 at 10:43











    • .col-left .block-left-nav li.active > a font-weight: bold;

      – Adam Allen
      Oct 17 '14 at 10:45















    0














    This could be a CSS related issue, please try to find the exact CSS being used for that block and try to see if any Bold font design has been written over there!






    share|improve this answer























    • There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

      – Adam Allen
      Oct 17 '14 at 10:32











    • The return in _isCurrentCategory($category), is it giving required output? place a log to check

      – Rahul Kumar Das
      Oct 17 '14 at 10:36











    • What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

      – Adam Allen
      Oct 17 '14 at 10:39











    • From frontend, could you check that which css property is making the bottom category BOLD?

      – Rahul Kumar Das
      Oct 17 '14 at 10:43











    • .col-left .block-left-nav li.active > a font-weight: bold;

      – Adam Allen
      Oct 17 '14 at 10:45













    0












    0








    0







    This could be a CSS related issue, please try to find the exact CSS being used for that block and try to see if any Bold font design has been written over there!






    share|improve this answer













    This could be a CSS related issue, please try to find the exact CSS being used for that block and try to see if any Bold font design has been written over there!







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 17 '14 at 9:42









    Rahul Kumar DasRahul Kumar Das

    1,6981119




    1,6981119












    • There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

      – Adam Allen
      Oct 17 '14 at 10:32











    • The return in _isCurrentCategory($category), is it giving required output? place a log to check

      – Rahul Kumar Das
      Oct 17 '14 at 10:36











    • What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

      – Adam Allen
      Oct 17 '14 at 10:39











    • From frontend, could you check that which css property is making the bottom category BOLD?

      – Rahul Kumar Das
      Oct 17 '14 at 10:43











    • .col-left .block-left-nav li.active > a font-weight: bold;

      – Adam Allen
      Oct 17 '14 at 10:45

















    • There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

      – Adam Allen
      Oct 17 '14 at 10:32











    • The return in _isCurrentCategory($category), is it giving required output? place a log to check

      – Rahul Kumar Das
      Oct 17 '14 at 10:36











    • What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

      – Adam Allen
      Oct 17 '14 at 10:39











    • From frontend, could you check that which css property is making the bottom category BOLD?

      – Rahul Kumar Das
      Oct 17 '14 at 10:43











    • .col-left .block-left-nav li.active > a font-weight: bold;

      – Adam Allen
      Oct 17 '14 at 10:45
















    There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

    – Adam Allen
    Oct 17 '14 at 10:32





    There is CSS because we need it to bold when the user is in the category. The problem is the bottom category is set to active when you are not in it.

    – Adam Allen
    Oct 17 '14 at 10:32













    The return in _isCurrentCategory($category), is it giving required output? place a log to check

    – Rahul Kumar Das
    Oct 17 '14 at 10:36





    The return in _isCurrentCategory($category), is it giving required output? place a log to check

    – Rahul Kumar Das
    Oct 17 '14 at 10:36













    What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

    – Adam Allen
    Oct 17 '14 at 10:39





    What do you mean is it giving required output? If you mean does it work as we want. Then yes, the parent category is bold when you are in it and so are the children categories. The problem is when you are in a parent category it is also setting the last child category to active as well even when you are not in it

    – Adam Allen
    Oct 17 '14 at 10:39













    From frontend, could you check that which css property is making the bottom category BOLD?

    – Rahul Kumar Das
    Oct 17 '14 at 10:43





    From frontend, could you check that which css property is making the bottom category BOLD?

    – Rahul Kumar Das
    Oct 17 '14 at 10:43













    .col-left .block-left-nav li.active > a font-weight: bold;

    – Adam Allen
    Oct 17 '14 at 10:45





    .col-left .block-left-nav li.active > a font-weight: bold;

    – Adam Allen
    Oct 17 '14 at 10:45













    0














    Maybe you're just getting this active class through some JavaScript code on frontend? I would start from checking all JavaScript related to the menu.






    share|improve this answer



























      0














      Maybe you're just getting this active class through some JavaScript code on frontend? I would start from checking all JavaScript related to the menu.






      share|improve this answer

























        0












        0








        0







        Maybe you're just getting this active class through some JavaScript code on frontend? I would start from checking all JavaScript related to the menu.






        share|improve this answer













        Maybe you're just getting this active class through some JavaScript code on frontend? I would start from checking all JavaScript related to the menu.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 19 '14 at 21:59









        zitixzitix

        1,09772141




        1,09772141



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f37696%2fbottom-category-on-left-navigation-is-always-open%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2