InsideDarkWeb.com

is creating block within template in magento 2 good practice

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?

Magento Asked by Herve Tribouilloy on July 24, 2020

0 Answers

Add your own answers!

Related Questions

Magento 2.4 PWA : How to setup with LEMP stack using Docker

0  Asked on October 1, 2021 by saditha-udayanga

         

Remove product attribute automatically

2  Asked on October 1, 2021

 

Error while saving custom fields on place order

0  Asked on March 6, 2021 by pramod

 

Watermark Category Images with Brand Logo

1  Asked on February 26, 2021 by ijeep

       

Issue With Displaying Gallery Widget

1  Asked on February 24, 2021 by magento_learner

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.