Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How would I change the main navigation? 
 
talkaboutdesign
Member
 
Total Posts:  34
Joined:  2007-11-07
 

Hey guys! Thanks for a great system, I am currently exploring theming and was wondering how would I switch from using a dropdown nav. What I want is something like this, http://www.abercrombie.com/

When you select a category you go to the subcategory page, and then list the subcategories like that. Your help would be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

Ahh, this is pretty easy.  You need to modify 2 files

app/design/frontend/default/default/templates/catalog/navigation/top.phtml

app/code/core/Mage/Catalog/Block/Navigation.php

The phtml template file is setup to do nested UL/LI navigation.  So modify it as you see fit to get your top level HTML the way you want.  It also calls “$this->drawItem($_category)” The $this is a reference to the Block/Navigaiton.php file that I listed above.  It recursively calls drawItem() to print more nested LIs.  So you have to rewrite that function to only print the current category and none of its children.

Now you have a row of just top level categories.

To do the sub categories, you probably want to continue coding on the top.phtml file.  It might be better to split this up into two files, but that would involved changing some XML and more template files.  You can do that later if you want.

At the very end of the file, you want to loop through all the top level categories again in a foreach.  If the category is active “$this->isCagegoryActive($_category)” then grab all its children “$_category->getChildren()”, do a nested foreach of those, and print them however you want.

Just two files… there’s better ways to do these customizations, but once you get your changes in, then you can start looking at how to move your changes around to protect them against upgrades.

 
Magento Community Magento Community
Magento Community
Magento Community
 
talkaboutdesign
Member
 
Total Posts:  34
Joined:  2007-11-07
 

What am I doing wrong here:

<?foreach ($this->isCagegoryActive($_category)?>
            <?
=$_category->getChildren()?>
<?endforeach?>

It gives me an error saying

Parse errorsyntax errorunexpected ';' in /mnt/gs02/herd03/30419/domains/maxandginosclothing.com/html/dev2/app/design/frontend/default/new_layout/template/catalog/navigation/top.phtml on line 51

Can you help me with the function?

 
Magento Community Magento Community
Magento Community
Magento Community
 
talkaboutdesign
Member
 
Total Posts:  34
Joined:  2007-11-07
 

Another thing I found is that when in top level menu such as womens category, items will show up for submenu, but when in submenu item they wont. Any help with this would be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

For your first question: which line is line 51 (the one giving you the error)? Include a couple of lines before it as well. By the way, in version 0.7.14800 this is even easier to do: in the above-mentioned top.phtml, all you need to do is change the “10” to a “1” in line 32:

<?foreach ($this->getStoreCategories(1) as $_category):?>
This tells Magento to limit recursion to 1 child level (meaning only the top category shows).

For your second question, I assume you mean the subcats don’t show up in the Layered Navigation box. Have you made the subcategories anchors? (in the “Manage Categories” section of the admin, General tab for each subcategory, near the bottom). Unless they’re anchors, they won’t show up in the Layered Navigation box on the left side.

 
Magento Community Magento Community
Magento Community
Magento Community
 
talkaboutdesign
Member
 
Total Posts:  34
Joined:  2007-11-07
 

Is there a different way to show subcategories?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top