我需要通過佈局更新引用調用將before
屬性附加到塊。Magento:使用來自local.xml佈局參考的before/after屬性更新塊位置
這是我local.xml
文件:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="content">
<block type="page/html_wrapper" name="content.footer" as="contentFooter" translate="label" after="-">
<label>Content Footer</label>
<action method="setElementId"><value>content-footer</value></action>
<action method="setElementClass"><value>clear</value></action>
</block>
</reference>
</default>
<catalog_category_default>
<reference name="breadcrumbs.container">
<action method="unsetChild"><name>category.title</name></action>
</reference>
<reference name="content">
<block type="catalog/category_view" name="category.title" template="catalog/category/title.phtml" before="content.footer"/>
</reference>
</catalog_category_default>
</layout>
我的問題是,在content
塊上創建一個content.footer
塊,你可以在管理員指定窗口小部件。我在content.footer
塊上使用after="-"
,所以在我看來,應該總是將它放在內容塊的底部,但情況並非如此。
當您查看目錄類別並將category.products
塊插入到content
塊中時,它將顯示在content.footer
塊的下面。使其工作的唯一方法是,如果我將其重新定義在我的local.xml
中,並將所有子塊包含在category.products
中,並在before="content.footer"
之前設置。
所以我想,爲什麼我不能用在catalog_category_default
佈局category.products
參考,並設置塊的before
屬性,我試過如下:
<reference name="category.products">
<action method="setBefore"><value>content.footer</value></action>
</reference>
其中有沒有影響。
我也注意到在Mage_Core_Block_Abstract
裏面看到它只是setData()
包裝的setAttribute()
功能,但想到我會繼續嘗試,仍然一無所獲:
<reference name="category.products">
<action method="setAttribute"><key>before</key><value>content.footer</value></action>
</reference>
是否有可能做我想做什麼?之前/之後只適用於相同參考中的塊嗎?
謝謝Ben!我認爲這可能是這種情況。由於我只是_really_需要它在目錄類別頁面中,我將從默認佈局中將其刪除,並在我執行其他更新時更新類別佈局,以便我可以將其強制到底部。 – Kus 2012-03-14 23:03:26