1

Can I retrieve a block instance using it's alias (as="alias") within a template?

I'm aware this can be done for the block name, for example:

$block->getLayout()->getBlock('BLOCK_NAME');

I'm looking for a way to do this using the alias specifically:

$block->getLayout()->getBlockByAlias('BLOCK_ALIAS');
0

In Magento 2 you are able to load block also by alias in this way:

echo $block->getChildHtml('BLOCK_ALIAS');
or
echo $this->getChildHtml('BLOCK_ALIAS');

Some useful info (also about blocks and rendering):
https://blog.philwinkle.com/the-most-misunderstood-concept-in-magento/

  • Either provide short answer in comment or provide more information – Gopal Patel Mar 7 '17 at 14:39
  • the question relates to magento 2 rather than magento 1 – minlare Mar 7 '17 at 15:05

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.