2

when i create block and insert like this,

$block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'reviewfororderproducts',array('template' => 'clarion/review.phtml '))->setData('data', $data);

it works fine $block->toHtml() returns a string with all html

but when i do like this

 $block = $this->getLayout()->createBlock('Clarion_ReviewReminder_Block_Allproducts', 'reviewfororderproducts',array('template' => 'clarion/review.phtml '))->setData('data', $data);

i can't get the block, $block->toHtml() returns null

my block class is only extends from Mage_Core_Block_Template

class Clarion_ReviewReminder_Block_Allproducts extends Mage_Core_Block_Template
{
    protected function _construct()
    {
        parent::_construct();
    }
}
5
  • Can you share the code from your block? Otherwise you're asking why 1 plus something doesn't equal something else
    – scrowler
    Jun 27, 2016 at 10:33
  • Clarion_ReviewReminder_Block_Allproducts extends Mage_Core_Block_Template { } Jun 27, 2016 at 10:37
  • If that's the only difference then why do you need it?
    – scrowler
    Jun 27, 2016 at 10:37
  • i don't have any code inside that Jun 27, 2016 at 10:38
  • @RobbieAverill i was having some functions, for debugging i deleted all the functions , Jun 27, 2016 at 10:39

1 Answer 1

1

If you don't have any custom code in your custom block and that block only extends Mage_Core_Block_Template there is no point using a custom block.

It is not bad practice to use Mage_Core_Block_Template whenever you need to use a template.

Debugging steps

I suggest you start in the toHtml method from Mage_Core_Block_Abstract.

Most of the time, empty HTML is caused by the fact that the module output is disabled in the backend but I don't think it's the case for you as you said it was returning null.

I suggest you add the following code in this method:

if ($this insteanceof Clarion_ReviewReminder_Block_Allproducts) {
    Mage::log($html);
}

Also add some logs to the _toHtml method of Mage_Core_Block_Template as weel as the fetchView method.

3

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.