1
我按照以下方式從模板調用塊。我知道這不是推薦的方法,但layout.xml方法給我帶來麻煩無法在模板中顯示塊 - magento
echo $this->getLayout()->createBlock('shoppingbasket/options')
->setTemplate('shoppingbasket/cart/item/default/options.phtml')
->setBlockId('options')
->setProduct($_item->getProduct())
->setSelectedOptions($this->getOptionList())
->toHtml() ?>
該塊得到渲染。現在我想通過layout.xml方法將其添加
我已經添加了塊到layout.xml如下:
<layout>
<checkout_cart_index>
<reference name="checkout.cart">
<block type="shoppingbasket/options" template="shoppingbasket/cart/item/default/options.phtml" name="options"></block>
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>shoppingbasket/cart/item/default.phtml</template></action>
</reference>
</checkout_cart_index>
</layout>
和我打電話從模板作爲塊如下:
<?php echo $this->getChildHtml('options') ?>
該塊沒有出現,我試着在layout.xml中隨處移動塊。我究竟做錯了什麼?還有一種方法可以使用layout.xml方法將參數傳遞到塊,就像我做的那樣
->setProduct($_item->getProduct())
->setSelectedOptions($this->getOptionList())
謝謝!
以及您在調用此模板的模板? –