Magento 1.9 – Fix Layered Navigation Not Showing

cmshomelayered-navigationmagento-1.9

I try put in CMS homepage, a layered navigation, the block is called but don't show any options.

in update xml i have:

 <reference name="root">
    <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="content">
    <block type="catalog/layer_view" name="catalog.leftnav.home" after="-" template="catalog/layer/homeview.phtml">
        <action method="setData"><name>category_id</name><value>2</value>

</action>
        </block>
    </reference>

homeview.phtml:

    <?php if($this->canShowBlock()): ?>
    <?php echo $this->getStateHtml() ?>

        <?php if ($this->getLayer()->getState()->getFilters()): ?>
            <div><a href="<?php echo $this->getClearUrl() ?>"><?php  echo $this->__('Clear All') ?></a></div>
        <?php endif; ?>

        <?php if($this->canShowOptions()): ?>


            <nav class="panel-filters">
                <?php $_filters = $this->getFilters() ?>

                <?php foreach ($_filters as $_filter): ?>

                    <?php if($_filter->getItemsCount()): ?>

                        <h3><?php echo $this->__($_filter->getName()) ?></h3>
                        <?php echo $_filter->getHtml() ?>

                    <?php endif; ?>

                <?php endforeach; ?>
            </nav>    

         <script type="text/javascript">decorateDataList('narrow-by-list')</script>

    <?php endif; ?>

<?php endif; ?>

The block don't show anything after $this>canShowBlock(). How i do it?

Best Answer

In the 'Layout Update XML' , if you use this code given below, it will show the layer navigation.

I'm not sure what is the purpose behind this requirement, because layer navigation will show options only for a category and if you click any filter link, it will add parameters to the the Home page URL.

<reference name="content">
<block category_id="3" type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
   <block type="core/text_list" name="catalog.leftnav.state.renderers" as="state_renderers" />
</block>
</reference>
Related Topic