Layout update programmatically in Magento 1.9.x
-
12-12-2020 - |
سؤال
I now work with sources of other developers and don't understand what for this code:
protected function _getShippingMethodsHtml() {
$layout = $this->getLayout();
$update = $layout->getUpdate();
$update->load('opcheckout_onepage_shippingmethod');
$layout->generateXml();
$layout->generateBlocks();
$output = $layout->getOutput();
return $output;
}
I am highly appreciated for any help.
المحلول
protected function _getShippingMethodsHtml() {
$layout = $this->getLayout();
$update = $layout->getUpdate(); //getLayout->getUpdate() you get the layout handle of your page, you can check it with this : <?php var_dump(Mage::app()->getLayout()->getUpdate()->getHandles());?>
$update->load('opcheckout_onepage_shippingmethod'); //you load this layout handle : opcheckout_onepage_shippingmethod
$layout->generateXml(); //generate a layout xml, see Mage_Core_Model_Layout
$layout->generateBlocks(); //You create layout blocks hierarchy from layout xml configuration, see Mage_Core_Model_Layout
$output = $layout->getOutput();
return $output; //get a rendered block
}
لا تنتمي إلى magento.stackexchange