1

The layout block <block class="Magento\Framework\View\Element\Text\ListText" loops through all its child blocks same as the container. Based on what I see, they have the same purpose. Can you tell me what are the differences between the two and which one is best to use?

2 Answers 2

4

In block text list return all of its child and you can add any number of block inside it.

While a container can have htmlTag and htmlClass attributes on which you can define tag name and html class to that tag.

And it will generate a Dom element with specified tag and class attribute and will inject all its child block into that Dom.

Using container you can define page layout without any template, you just need to write your XML layout with containers.

While you need to create many templates for each block to define layout design.

0

Container

Outputs an HTML element and optional class attribute

ListText Block

Does not output an HTML element, but has the benefit of allowing data set via XML by use of <arguments>


If you need an actual HTML element wrapper, use a <container>. If you do not want an element or need to send data, use a "ListText" <block>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.