0

I've been reading some tutorials and some use:

$this->getLayout()

To get the current layout, while others use:

Mage::getSingleton('core/layout');

I was wondering if there's any difference between the two approaches.

The calls are being run from a controller class that extends Mage_Core_Controller_Front_Action.

Thanks

0

$this->getLayout() is a shortcut for Mage::getSingleton('core/layout'), so technically there is no difference.

But note that, Mage::getSingleton('core/layout') works everywhere, while $this->getLayout() only works in controllers or blocks, i.e. classes that implement this shortcut method.

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.