Hi
I am little bit confused about refrenceBlock and refrenceContainer , Block
When should we use these what is the purpose of these elements
Can Anyone clear out all of these.
Thanks
@krishenuetb254 Following are major difference between both of them:
Container: Using container we can create a new blank HTML dom using htmlClass and htmlDiv attribute of container. This is to create a blank HTML dom.
ReferenceContainer: There is already a container exist and you want to put your block or container in that container we use referenceContainer tag.
Block: Block works as mediator of our phtml file and the business logic. In block we define the PHP class and the phtml file path and it works to connect both of them. In PHTML file if call the function of block class that is provided in class attribute of tag.
ReferenceBlock: ReferenceBlock is used when we want to use already existing block and want to put our block in that existing block. We use this if we want to add changes to phtml file of that block. In the PHTML file of existing block we use $block->getChild('name_of_child_block') function to render the output of child block.
For more details you can follow documentations:
https://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-instructions.html
Hope it helps!
Thanks