0

I am trying to create a custom page for which I have the following XML using an empty template.

In my Controller, I have

public function indexAction()
{
        $this->loadLayout();
        $this->getLayout()->getBlock('root')->setTemplate('page/empty.phtml');
        $this->renderLayout();
}

And in my layout, I have

<?xml version="1.0"?>
<layout version="0.1.0">
    <brands_index_index>
        <reference name="content">
            <block type="catalog/layer_view" name="catalog.leftnav" before="brands" template="catalog/layer/view.phtml"/>
            <block type="core/template" name="brands" template="brands/brands.phtml" />
        </reference>
    </brands_index_index>
</layout>

This works fine and the layered navigation is displayed.

However, I want the layered navigation to be displayed within the brands.phtml template. Thus, I tried to do the following:

<?xml version="1.0"?>
<layout version="0.1.0">
    <brands_index_index>
        <reference name="content">
            <block type="core/template" name="brands" template="brands/brands.phtml" >
                <block type="catalog/layer_view" name="catalog.leftnav" as="catalog.leftnav" template="catalog/layer/view.phtml"/>
            </block>
        </reference>
    </brands_index_index>
</layout>

However, this does not seem to work when I call getChildHtml("catalog.leftnav") within brands.phtml.

How do I shift the layered navigation to where I need to call it in brands.phtml?

So, it seems like the block is loaded when I view the "rendered blocks" section in "Magento Debug".. However, no HTML is generated. Is there a rule that says that the layered navigation has to be in the left/content/right blocks or something?

THanks

henrybai
  • 210
  • 3
  • 10

1 Answers1

0

getChildHtml looks for children using their as attribute, not their name attribute. So try changing your block definition to this and change the getChildHtml call accordingly:

<block type="catalog/layer_view" name="catalog.leftnav" as="mynav" template="catalog/layer/view.phtml" />
wierdo
  • 426
  • 2
  • 5
  • FWIW, you might note that the Magento team doesn't make name and as the same value. I don't know if there's a technical reason for that or if it's just a stylistic choice. – wierdo Apr 28 '13 at 21:29
  • Oh, it looks like you need to get the layer model and call its setCurrentCategory method to get anything useful out of it. – wierdo Apr 28 '13 at 21:41