|
emagine - 26 April 2008 09:00 AM
<div class="box layered-nav"> <div class="head"> <h3><?php echo $this->__('Browse By') ?></h3> </div> <div class="border-creator"> <div class="narrow-by"> <dl id="narrow-by-list"> <dd> <ol> <?php foreach ($this->getStoreCategories() as $_category): ?> <dt> <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="active"<?php endif ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> </dt> <?php endforeach ?> </ol> </dd> </dl><script type="text/javascript">decorateDataList('narrow-by-list')</script> </div> </div> </div>
Is there any way to make this code so only the sub categories of the current clicked category shows up?
You can do that with css. Active categories are tagged that way automatically. So you just need to hide all subcategories but those with class .active. (From the top of my head so you should check)
With firefox you can select a ‘piece of webpage’, say for instance a couple subcategories, richt click it and “view selection source”, do the same for active subcategories so you can compare the code. All that’s left is applying the correct style.
something like this:
li li { display:none;} li li.active { display:block}
Lots of tutorials on the web to explain you in detail how this works.
This is one to get you started: http://www.alistapart.com/articles/dropdowns
BTW, you’re working with a template that has layered navigation and category navigation mixed together. For menu’s I think you’re better off working with lists, for instance:
<div class="left-nav-container"> <div class="left-nav"> <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4> <ul id="nav"> <?php foreach ($this->getStoreCategories() as $_category): ?> <?php echo $this->drawItem($_category) ?> <?php endforeach ?> </ul> </div> </div>
asfaltagmail - 15 April 2008 03:50 PM Ben:
I followed your steps but don’t see any change at my frontpage. Can you please be more specific about where edit and replace or add your code?
Thank you very much
Andrea
Sorry, I’m not always getting notifications of replies so I missed yours.
I’ll try to be more specific, btw, did you set your categories to be anchors?
catalog.xml:
<reference name="left"> <block type="catalog/navigation" name="catalog.vertnav" template="catalog/navigation/left_cat_nav.phtml" /> </reference>
More detailed version:
<default>
<!-- Mage_Catalog --> <reference name="top.menu"> <block type="catalog/navigation" name="catalog.nav" template="catalog/navigation/top.phtml" /> </reference> <reference name="left"> <block type="catalog/navigation" name="catalog.vertnav" template="catalog/navigation/left_cat_nav.phtml" /> </reference>
I then created the following file in magento/app/design/frontend/default/templatename/template/catalog/navigation/
left_cat_nav.phtml
<div class="left-nav-container"> <div class="left-nav"> <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4> <ul id="nav"> <?php foreach ($this->getStoreCategories() as $_category): ?> <?php echo $this->drawItem($_category) ?> <?php endforeach ?> </ul> </div> </div>
Also make sure that in the backend, under “design” in the configuration section, that you enter “templatename” 3 times; for “templates”, “skin” and “layout”.
|