[英]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.