Posts

Showing posts with the label blocks

References and blocks

  How to set in magento xml layout a new block class for an existing block? Also how to set it not cacheable? To set a new block class for an existing block in Magento 2, you can use the "referenceBlock" tag in your XML layout file. Here's a simple example: Find the block's name. It is usually set in the XML layout file of the module where the block is created. Create your own custom block class by extending the original block class in your module. In your module's XML layout file, use the "referenceBlock" tag to update the existing block's class. Here's an example of the XML layout code: < page xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance " xsi: noNamespaceSchemaLocation = " urn:magento:framework:View/Layout/etc/page_configuration.xsd " > < body > < referenceBlock name = " block_name " > < arguments > < argument name = " bloc...