0

In controller

....
      $this->_initAction();
//        $this->loadLayout();
        $update = $this->getLayout()->getUpdate();
        $update->addHandle('default');
        $this->addActionLayoutHandles();
        $update ->removeHandle('shopbybrand_index_view')
                ->addHandle('catalog_category_default')
                ->addHandle('catalog_category_view')
                ->addHandle('catalog_category_layered')

                ->addHandle('shopbybrand_index_view');
        $this->loadLayoutUpdates();
        $this->generateLayoutXml();
        $this->generateLayoutBlocks();
        $this->_isLayoutLoaded = true;
....

in list.phtml:

   <?php
$block = Mage::app()->getLayout()->createBlock('shopbybrand/productinfo')->setTemplate('shopbybrand/namebrand.phtml')->toHtml();
echo $block;
?>

But nothing show, same code in view.phtml, block shows fine!!

+/

    Getproduct in productinfo.php

        public function getProduct(){
                 $product = Mage::registry('current_product');
                return $product;
            }
  • Depends what the contents of the shopbybrand/productinfo does. If it's working on the product page it might be that it's pulling in information from Mage::registry('current_product') and doesn't display anything unless this is set. – Peter O'Callaghan Feb 21 '16 at 18:13
  • yes I find public function getProduct(){ $product = Mage::registry('current_product'); return $product; } so what can i do? – Trong Tran Xuan Feb 22 '16 at 1:30
0

Please remove $this->loadLayout();

  1. If you add your handle before you call $this->loadLayout() from a controller it's too soon.

  2. If you add your handle after you call $this->loadLayout() it's too late.

More information here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.