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

Page 2 of 6
Layered navigation at home page? 
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Can you post the code you used where it worked?  Mine is having the same problem ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

Hi sherrie,

The code i have in homeview.phtml is this:

<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
    <
div class="block-title">
        <
h3><?php echo $this->__('Shop by'?></h3>
    </
div>
    <
div class="block-content">
        
<?php echo $this->getStateHtml() ?>
        <?php 
if($this->canShowOptions()): ?>
            
<!--<h3><?php // echo $this->__('Shopping Options') ?></h3>-->
            
<dl>
                
<?php $_filters $this->getFilters() ?>
                <?php 
foreach ($_filters as $_filter): ?>
                <?php 
if($_filter->getItemsCount()): ?>
                    
<dt><?php echo $_filter->getName() ?></dt>
                    <
dd><?php echo str_replace(array('?','/?'),array('rootusados?','/rootusados?'),$_filter->getHtml()) ?></dd>
                
<?php endif; ?>
                <?php 
endforeach; ?>
            
</dl>
        
<?php endif; ?>
    
</div>
</
div>
<?php endif; ?>

My links doesn’t work because i have this line like this:

<?php echo str_replace(array('?','/?'),array('ROOTCATEGORY?','/ROOTCATEGORY?'),$_filter->getHtml()) ?>

And my category URL Key is rootusados, so I changed to this:

<?php echo str_replace(array('?','/?'),array('rootusados?','/rootusados?'),$_filter->getHtml()) ?>

And the links start working properly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

I take a look in your project: http://www.minervapromotions.com/techusa/ and i see that your root category for layered navigation doesn’t appear in the menu bar, how do you do that??

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Well I have the layered navigation category set to the root of the normal navigation, but it’s not functioning correctly. I’m not sure if that’s the problem or not.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

My menus should be like in non_working_front_end.png (images atached).
But when the menus looks like this the layered navigation doesn’t work. In that situation my category tree looks like non_working.png .

When I change my category tree to something like working.png the Layered Navigation in home page works perfectly but my layered navigation root category appears in the front-end (working_front_end.png). I don’t want my layered navigation root category to appear in my front-end menu bar.

Can you show me how you have yours??

Image Attachments
non_working.pngnon_working_front_end.pngworking.pngworking_front_end.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Mine is just like yours actually, if you try to narrow it you’ll see it’s not working either - I thought you had yours working which is why I asked what your code looks like.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Actually mine is assigned to a different root category right now, but it still goes to a bad URL.

My homeview.phtml code is:

<?php if($this->canShowBlock()): ?>
    
<div class="box layered-nav">
        <
div class="head">
            <
h3 class="title"><?php echo $this->__('Shop by'?></h3>
        </
div>
        

        
<?php echo $this->getStateHtml() ?>
        <?php 
if($this->canShowOptions()): ?>
        
<div class="content no-padding">
            <
div class="narrow-by">
                <
dl id="narrow-by-list">
                    
<?php $_filters $this->getFilters() ?>
                    <?php 
foreach ($_filters as $_filter): ?>
                    <?php 
if($_filter->getItemsCount()): ?>
                    
<dt><?php echo $_filter->getName() ?></dt>
                    <
dd>
                    
<?php echo str_replace(array('?','/?'),array('home-page-2?','/home-page-2?'),$_filter->getHtml()) ?>
                    
</dd>
                    
<?php endif; ?>
                    <?php 
endforeach; ?>
                
</dl>
                <
script type="text/javascript">decorateDataList('narrow-by-list')</script>
            
</div>
        </
div>
        
<?php endif; ?>
    
</div>
<?php endif; ?>
<!-- [ends] .browse-by // -->
 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

Every thing looks ok in your code.

What I can suggest you to do is to delete your current layered navigation root category and create a new one and add home-page-2 as URL Key from your new Root Category.

If you don’t want to delete your root category you can search for it in data base and see if it URL Key is home-page-2.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

You can see my working Layered Navigation here: http://stand.mmediasolutions.eu/

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

What does your IndexController.php code look like?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

My IndexController.php looks like this:

class Mage_Cms_IndexController extends Mage_Core_Controller_Front_Action
{
    
public function indexAction($coreRoute null)
    
{
        
// ADICIONADO POR HERCILIO PARA TER LAYERED NAVIGATION NA HOME PAGE - VISTO EM: http://www.magentocommerce.com/boards/viewthread/4810/
        
        
$categoryId 17// ID OF CATEGORY YOU WANT ON HOMEPAGE
            
        
$category Mage::getModel('catalog/category')
            ->
setStoreId(Mage::app()->getStore()->getId())
            ->
load($categoryId);

        if (!
Mage::helper('catalog/category')->canShow($category)) {
            
return false;
        
}
        
        Mage
::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
        
Mage::register('current_category'$category); 
        
        
// FIM DE ADIÇÃO 
        
        
$pageId Mage::getStoreConfig('web/default/cms_home_page');
        if (!
Mage::helper('cms/page')->renderPage($this$pageId)) {
            $this
->_forward('defaultIndex');
        
}
    }
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

This is so strange - when I add that into my IndexController.php I get a blank front page on my site.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

You get a blank Home Page because of your category ID.

You need to change this:

$categoryId 17// ID OF CATEGORY YOU WANT ON HOMEPAGE

To see your root category ID you can follow this link: http://www.magentocommerce.com/boards/viewthread/17998/#top

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hercilio Costa
Member
 
Total Posts:  59
Joined:  2008-07-15
 

Can I see your IndexController.php code???

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Of course, ...

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Mage
 * @package    Mage_Cms
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

class Mage_Cms_IndexController extends Mage_Core_Controller_Front_Action
{
    
public function indexAction($coreRoute null)
    
{
         
        $categoryId 
2
            
        
$category Mage::getModel('catalog/category')
            ->
setStoreId(Mage::app()->getStore()->getId())
            ->
load($categoryId);

        if (!
Mage::helper('catalog/category')->canShow($category)) {
            
return false;
        
}
        
        Mage
::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
        
Mage::register('current_category'$category); 
        
      
        
$pageId Mage::getStoreConfig('web/default/cms_home_page');
        if (!
Mage::helper('cms/page')->renderPage($this$pageId)) {
            $this
->_forward('defaultIndex');
        
}
    }

    
public function defaultIndexAction()
    
{
        $this
->getResponse()->setHeader('HTTP/1.1','404 Not Found');
        
$this->getResponse()->setHeader('Status','404 File not found');

        
$this->loadLayout();
        
$this->renderLayout();
    
}

    
public function noRouteAction($coreRoute null)
    
{
        $this
->getResponse()->setHeader('HTTP/1.1','404 Not Found');
        
$this->getResponse()->setHeader('Status','404 File not found');

        
$pageId Mage::getStoreConfig('web/default/cms_no_route');
        if (!
Mage::helper('cms/page')->renderPage($this$pageId)) {
            $this
->_forward('defaultNoRoute');
        
}
    }

    
public function defaultNoRouteAction()
    
{
        $this
->getResponse()->setHeader('HTTP/1.1','404 Not Found');
        
$this->getResponse()->setHeader('Status','404 File not found');

        
$this->loadLayout();
        
$this->renderLayout();
    
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 6