TransWikia.com

is creating block within template in magento 2 good practice

Magento Asked by Herve Tribouilloy on July 24, 2020

I often see in phtml templates blocks being creating dynamically like below:

$block->getLayout()->createBlock(BlockClass)->toHtml();

I worry whether this is good practice and particularly whether the block will be cached eventually or whether it can create an overhead in the page load?

Has anybody any ideas whether the cache is not applying for these blocks?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP