Magento Forum

   
Poll
Are you interested in arranging your navigation this way but don't know how?
Yes 10
No 1
Total Votes: 11
You must be a logged-in member to vote
Navigation: Pages & Categories
 
Oxa Koba
Jr. Member
 
Avatar
Total Posts:  8
Joined:  2008-04-15
Oregon, United States
 

Navigation: Pages & Categories

I am having trouble rearranging the navigation to suit my needs. Here is the goal:

1. CMS Pages (created via CMS > Manage Pages ) should appear as the primary navigation in the menu across the top.

2. Top-level categories should appear as a navigation list in the left sidebar. (This is different than the “layered navigation” which is really a filter not a simple navigation list).

It should be possible to do this without hard-coding the links into the PHTML (as proposed elsewhere). The PHP found in catalog/navigation/top.phtml that generates a unorder-list of categories to be placed in the menu bar should be easily repurposed to do both goals listed above. That codes is as follows:

<?php foreach ($this->getStoreCategories() as $_category): ?>
    <?php 
echo $this->drawItem($_category?>
<?php 
endforeach ?>

So how do I call the list of pages to assemble as a list using similar PHP code?

And how can I use this code to generate left sidebar navigation composed of categories?

Thank you for suggestions.

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoshBelke
Member
 
Total Posts:  64
Joined:  2008-02-12
NY, NY
 

1) Strip the

Nav from top.phtml

you have
2) Add

Nav to left.phtml

3) Modify

drawItem() core/Mage/Catalog/Block/Navigation.php and /skin/.../css/menu & boxes.css

4) make a

“home" category in the admin, (note the category id.)

5) go into

core/Mage/Catalog/Model/Layer.php

and check to see if $categories are empty and: append code to
getCurrentCategory()  $this->setData('current_category'Mage::getModel("catalog/category')-> load(7); $category = $this->getData('current_category');
6) open up your home page CMS in the admin, and add
{{block type="catalog/product_list" category_id="7" template="catalog/product/list.phtml"}}

When I get more time Ill make it a better tutorial.
But for now I hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dunk
Jr. Member
 
Total Posts:  24
Joined:  2008-02-24
 

I don’t know if this is what you want or whether there is an easier way but I made my left navigation by adding a recursive function to app/code/core/Mage/Catalog/Block/Navigation.php as follows:

public function drawChildren($_category){
    $html
='';
    if(
$this->isCategoryActive($_category)){
         $html 
'<ul class="indentedUl">';
            foreach(
$_category->getChildren() as $_childCategory){
                     $html 
.= '<li>';
                     
$html .= '<a href="'.$this->getCategoryUrl($_childCategory).'"';
                    if (
$this->isCategoryActive($_childCategory)){
                         $html 
.= 'class="activeNav"';
                    
}else{
                         $html 
.= 'class="inactiveNav"';
                    
}
                     $html 
.= '>&raquo;&nbsp;'.$_childCategory->getName().'</a>';
                    
                    
//NEXT LVL
                     
$html .= $this->drawChildren($_childCategory);
                    
                     
$html .= '</li>';
            
}
         $html 
.= '</ul>';
    
}
    
return  $html;
}

then added the following to template/catalogue/navigation/left.phtml:

<ul>
<?foreach ($this->getStoreCategories() as $_category):?>
    
<li>
        
<?if ($this->isCategoryActive($_category)):?>
            
<a href="<?=$this->getCategoryUrl($_category)?>" class="activeNav"><?=strtoupper($_category->getName())?></a>
        
<?else:?>
            
<a href="<?=$this->getCategoryUrl($_category)?>" class="inactiveNav"><?=strtoupper($_category->getName())?></a>
        
<?endif;?>
        
        <? 
            $output 
$this->drawChildren($_category);
            echo  
$output;
        
?>
    
</li>
<?endforeach?>
</ul>

and called left.phtml instead of the layered navigation in the xml’s. There is probably a much simpler way but i got fed up trying to find it so wrote my own function instead. Also navigation.php has a function called drawOpenCategoryItem() which is pretty similar but seemed to open everything when I used it (I didn’t notice it until I had already written the function! typical)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jayson44
Member
 
Total Posts:  36
Joined:  2009-08-17
 

this is done on the magento classic theme demo page: http://freedemo.templates-master.com/f002

however, I’m not able to get it to work either.  there has to be an easier way to do this!

J.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rbradish
Jr. Member
 
Total Posts:  1
Joined:  2009-10-29
 
Jayson44 - 18 August 2009 04:55 AM

this is done on the magento classic theme demo page: http://freedemo.templates-master.com/f002

however, I’m not able to get it to work either.  there has to be an easier way to do this!

J.

I’m using this theme on my site and am curious about the same things already mentioned as well.

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