let's say i set my navigation categories as (Clothes, Shoes, Accessories, Help). In the CSS file i am able to change the color of the text to say RED, this changes the color of all categories (Clothes, Shoes, Accessories, Help) to red. What i want is Help to be Blue so that it stands out, is there any way to do that?
Magento – Change Individual Category Text Color in Navigation Menu
menunavigation
Related Solutions
After struggling a bit here is the solution I found. I let my observer execute after the one in Mage_Catalog
and decided to re-create the menu entirely.
The main idea is to get all the existing menu items put them in a temporary array, remove them from the menu then add my links between the existing items and in the end add all items to the menu again. Something like this:
public function addItemsToTopmenuItems($observer){
//get the menu object -Type Varien_Data_Tree_Node
$menu = $observer->getMenu();
//get the tree object in the menu -type Varien_Data_Tree
$tree = $menu->getTree();
//get current page handler
$action = Mage::app()->getFrontController()->getAction()->getFullActionName();
$brandNodeId = 'category-node-brand';
//set the node id, label and url
$data = array(
'name' => Mage::helper('catalog')->__('Brands'),
'id' => $brandNodeId,
'url' => Mage::getUrl('brands'),
'is_active' => ($action == 'brands')
);
//create a node object
$brandNode = new Varien_Data_Tree_Node($data, 'id', $tree, $menu);
//temporary array with nodes
$menuItems = array();
//my first menu item
$menuItems[] = $brandNode;
//loop through existing menu items, add them to the array and remove them from the menu
foreach ($menu->getChildren() as $child){
//add the item to the temp array
$menuItems[] = $child;
//remove item from the menu
$menu->removeChild($child);
//I need to add a new menu item after the category with id 6
//don't worry the id is not hard coded. it comes from a config setting
//I just added 6 here to make it easier to read
if ($child->getId() == 'category-node-6'){
//create a new node as $brandNode called $newNode
...
//add the node to my temp array
$menuItems[] = $newNode;
}
}
//add other nodes at the end of my temp array
...
//recreate the menu in the order I need
foreach ($menuItems as $child){
$menu->addChild($child);
}
}
This seams to solve my problem,but I'm hoping for a more elegant method of doing it.
I had same problem, after some coding I made this in template/catalog/navigation/left.phtml:
first line:
<?php $ct = Mage::registry('current_category')->getID(); ?>
in the end of the file(before endif;)
<?php elseif( $ct == 92 || $ct == 85 || $ct == 224): ?>
<?php
$currentcategory = Mage::registry('current_category');
$subcategorys = explode(',' , $currentcategory->getChildren());
?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Browse By') ?></span></strong>
</div>
<div class="block-content">
<dl id="narrow-by-list2">
<dt><?php echo $this->__('Category') ?></dt>
<dd>
<ol>
<?php foreach($subcategorys as $cat): ?>
<?php $cate = Mage::getModel('catalog/category')->load($cat); ?>
<li>
<a href="<?php echo $cate->getUrl()?>" <?php if ($this->isCategoryActive($cate)): ?> class="current"<?php endif; ?>><?php echo $this->escapeHtml($cate->getName()) ?>(<?php echo $cate->getProductCount() ?>) </a>
</li>
<?php endforeach; ?>
</ol>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list2')</script>
</div>
</div>
<?php endif; ?>
Best Answer
Magento assigns a unique class to each of the top level list item elements. If Help is the 4th category, you can select it with the 'nav-4' class. To change the text color, you can do this: