繁体   English   中英

Magento布局和分层导航

[英]Magento Layout and Layered Navigation

我试图创建一个自定义页面,使用空模板为其提供以下XML。

在我的控制器中,我有

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

在我的布局中

<?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>

这可以正常工作,并显示分层导航。

但是,我希望分层导航显示在brand.phtml模板中。 因此,我尝试执行以下操作:

<?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>

但是,当我在brand.phtml中调用getChildHtml(“ catalog.leftnav”)时,这似乎不起作用。

如何将分层导航移动到需要在brand.phtml中进行调用的位置?

因此,当我在“ Magento调试”中查看“渲染的块”部分时,似乎加载了该块。但是,没有生成HTML。 是否有规则说分层导航必须在left / content / right块之内?

谢谢

getChildHtml使用其as属性(而不是其name属性)查找子级。 因此,尝试将您的块定义更改为此,并相应地更改getChildHtml调用:

<block type="catalog/layer_view" name="catalog.leftnav" as="mynav" template="catalog/layer/view.phtml" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM