0

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?

1
  • Did the below answer help you? If so can you accept it as the solution?
    – philwinkle
    May 10, 2016 at 20:22

1 Answer 1

1

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>
4
  • See how it is: i.imgur.com/cEi698d.png Apr 22, 2015 at 16:07
  • Ensure you have passed the category_id parameter for the category for which you'd like to show this layer navigation and ensure you have set Is_Anchor-> Yes for that category in the CMS
    – vithyalega
    Apr 22, 2015 at 16:38
  • Yes, i changed the category id and i checked if the is_anchor -> yes, but does not have effect Apr 22, 2015 at 17:03
  • This works only if you have the RWD theme setup. If the not, try this: <reference name="content"> <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/> </reference>
    – vithyalega
    Apr 23, 2015 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.