What is the functional difference of Block & Container in Magento 2?
Block vs Container functional difference.
I have followed this url but doesn't clear much for me.
Which type of classes are extended by block and container.
Note : I know how containers and Block with everything else all works.
I want to understand Magento classes which are extended by block and container that implements rendering of a particular block & container, And also How it handles rendering child elements during view output generation.
magento2 blocks containers
add a comment |
Block vs Container functional difference.
I have followed this url but doesn't clear much for me.
Which type of classes are extended by block and container.
Note : I know how containers and Block with everything else all works.
I want to understand Magento classes which are extended by block and container that implements rendering of a particular block & container, And also How it handles rendering child elements during view output generation.
magento2 blocks containers
1
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday
add a comment |
Block vs Container functional difference.
I have followed this url but doesn't clear much for me.
Which type of classes are extended by block and container.
Note : I know how containers and Block with everything else all works.
I want to understand Magento classes which are extended by block and container that implements rendering of a particular block & container, And also How it handles rendering child elements during view output generation.
magento2 blocks containers
Block vs Container functional difference.
I have followed this url but doesn't clear much for me.
Which type of classes are extended by block and container.
Note : I know how containers and Block with everything else all works.
I want to understand Magento classes which are extended by block and container that implements rendering of a particular block & container, And also How it handles rendering child elements during view output generation.
magento2 blocks containers
magento2 blocks containers
edited 2 days ago
asked Jan 2 at 14:14
Aditya Shah
3,5452834
3,5452834
1
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday
add a comment |
1
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday
1
1
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday
add a comment |
4 Answers
4
active
oldest
votes
Container is a concept to create structure in both your layout and your html page:
I had a play with containers before writing this post and below you can see an example how to use it:
<referenceContainer name="content">
<container htmlId="mycontainer" name="mycontainer" htmlTag="ol">
<block name="test" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some text</li>]]></argument>
</arguments>
</block>
<block name="testw" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some other text</li>]]></argument>
</arguments>
</block>
</container>
As you can see below, the container has no physical ties like a block: the block is having a Block class and a template
To a container, you can assign css class, html id, html tag type (see the example above). The container eventually sits as a html tag in your page and will render all its block and child containers.
Finally, both can be referenced in the layout in the same and that is possibly where your confusion come from.
add a comment |
Well, if you ask about a functional difference I think the answer should be clear. Blocks, and this is the same as it was in Magento1, have always a concrete block class associated. On the other hand, containers can't have any specific class associated, as they seem to have been created in Magento2 just as some wrappers of page content / sections
https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html
In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3). These terms are illustrated and defined below.
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
add a comment |
I think Block and Container are different entity so there is no need to compare each other.
But here are some functional similarity between each-other.
For Ex: If you want to Extend (change the default behavior) of Block & Container you can use like this.
<referenceContainer name="content"></referenceContainer>
And
<referenceBlock name="product.info.addtocart"></referenceBlock>
A block can have the following features:
- A block can contain other blocks.
- A block can be used in several pages and blocks.
Example
A block MagentoUiTestBlockMessages
extends a basic block MagentoMtfBlockBlock
and implements methods to interact with messages.
Magento contains basic blocks for the functional testing with a logic that you can reuse. The most popular are the following:
- MagentoMtfBlockBlock
- MagentoMtfBlockForm
- MagentoBackendTestBlockWidgetTab
- MagentoBackendTestBlockWidgetFormTabs
- MagentoBackendTestBlockWidgetGrid
- MagentoUiTestBlockAdminhtmlDataGrid
For better understand go through below reference link.
- Block documentration
- Container documentration
I hope it helps!
add a comment |
Both containers and blocks are basic components of the Magento page structure. Containers make up the framework of a page and they can be either empty or contain child elements: it could be blocks and other containers.
An example of the container and blocks:
<container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
<block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
</container>
According to your question about child elements there is a Before/after attribute both for container and blocks. This attribute sets the order in which blocks and containers are displayed on a page.
More about containers and blocks you can read here.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256478%2fwhat-is-the-functional-difference-of-block-container-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Container is a concept to create structure in both your layout and your html page:
I had a play with containers before writing this post and below you can see an example how to use it:
<referenceContainer name="content">
<container htmlId="mycontainer" name="mycontainer" htmlTag="ol">
<block name="test" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some text</li>]]></argument>
</arguments>
</block>
<block name="testw" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some other text</li>]]></argument>
</arguments>
</block>
</container>
As you can see below, the container has no physical ties like a block: the block is having a Block class and a template
To a container, you can assign css class, html id, html tag type (see the example above). The container eventually sits as a html tag in your page and will render all its block and child containers.
Finally, both can be referenced in the layout in the same and that is possibly where your confusion come from.
add a comment |
Container is a concept to create structure in both your layout and your html page:
I had a play with containers before writing this post and below you can see an example how to use it:
<referenceContainer name="content">
<container htmlId="mycontainer" name="mycontainer" htmlTag="ol">
<block name="test" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some text</li>]]></argument>
</arguments>
</block>
<block name="testw" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some other text</li>]]></argument>
</arguments>
</block>
</container>
As you can see below, the container has no physical ties like a block: the block is having a Block class and a template
To a container, you can assign css class, html id, html tag type (see the example above). The container eventually sits as a html tag in your page and will render all its block and child containers.
Finally, both can be referenced in the layout in the same and that is possibly where your confusion come from.
add a comment |
Container is a concept to create structure in both your layout and your html page:
I had a play with containers before writing this post and below you can see an example how to use it:
<referenceContainer name="content">
<container htmlId="mycontainer" name="mycontainer" htmlTag="ol">
<block name="test" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some text</li>]]></argument>
</arguments>
</block>
<block name="testw" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some other text</li>]]></argument>
</arguments>
</block>
</container>
As you can see below, the container has no physical ties like a block: the block is having a Block class and a template
To a container, you can assign css class, html id, html tag type (see the example above). The container eventually sits as a html tag in your page and will render all its block and child containers.
Finally, both can be referenced in the layout in the same and that is possibly where your confusion come from.
Container is a concept to create structure in both your layout and your html page:
I had a play with containers before writing this post and below you can see an example how to use it:
<referenceContainer name="content">
<container htmlId="mycontainer" name="mycontainer" htmlTag="ol">
<block name="test" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some text</li>]]></argument>
</arguments>
</block>
<block name="testw" class="MagentoFrameworkViewElementText">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[<li>this is some other text</li>]]></argument>
</arguments>
</block>
</container>
As you can see below, the container has no physical ties like a block: the block is having a Block class and a template
To a container, you can assign css class, html id, html tag type (see the example above). The container eventually sits as a html tag in your page and will render all its block and child containers.
Finally, both can be referenced in the layout in the same and that is possibly where your confusion come from.
answered Jan 2 at 14:56
Herve Tribouilloy
1,199410
1,199410
add a comment |
add a comment |
Well, if you ask about a functional difference I think the answer should be clear. Blocks, and this is the same as it was in Magento1, have always a concrete block class associated. On the other hand, containers can't have any specific class associated, as they seem to have been created in Magento2 just as some wrappers of page content / sections
https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html
In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3). These terms are illustrated and defined below.
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
add a comment |
Well, if you ask about a functional difference I think the answer should be clear. Blocks, and this is the same as it was in Magento1, have always a concrete block class associated. On the other hand, containers can't have any specific class associated, as they seem to have been created in Magento2 just as some wrappers of page content / sections
https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html
In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3). These terms are illustrated and defined below.
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
add a comment |
Well, if you ask about a functional difference I think the answer should be clear. Blocks, and this is the same as it was in Magento1, have always a concrete block class associated. On the other hand, containers can't have any specific class associated, as they seem to have been created in Magento2 just as some wrappers of page content / sections
https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html
In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3). These terms are illustrated and defined below.
Well, if you ask about a functional difference I think the answer should be clear. Blocks, and this is the same as it was in Magento1, have always a concrete block class associated. On the other hand, containers can't have any specific class associated, as they seem to have been created in Magento2 just as some wrappers of page content / sections
https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html
In Magento, the basic components of page design are layouts, containers, and blocks. A layout represents the structure of a web page (1). Containers represent the placeholders within that web page structure (2). And blocks represent the UI controls or components within the container placeholders (3). These terms are illustrated and defined below.
answered Jan 2 at 14:42
Raul Sanchez
1,83231135
1,83231135
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
add a comment |
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
No :) , I mean which type of classes are extended by block and container.
– Aditya Shah
Jan 2 at 14:45
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Don't understand what you are asking then :)
– Raul Sanchez
Jan 2 at 15:00
Updated the question :)
– Aditya Shah
2 days ago
Updated the question :)
– Aditya Shah
2 days ago
add a comment |
I think Block and Container are different entity so there is no need to compare each other.
But here are some functional similarity between each-other.
For Ex: If you want to Extend (change the default behavior) of Block & Container you can use like this.
<referenceContainer name="content"></referenceContainer>
And
<referenceBlock name="product.info.addtocart"></referenceBlock>
A block can have the following features:
- A block can contain other blocks.
- A block can be used in several pages and blocks.
Example
A block MagentoUiTestBlockMessages
extends a basic block MagentoMtfBlockBlock
and implements methods to interact with messages.
Magento contains basic blocks for the functional testing with a logic that you can reuse. The most popular are the following:
- MagentoMtfBlockBlock
- MagentoMtfBlockForm
- MagentoBackendTestBlockWidgetTab
- MagentoBackendTestBlockWidgetFormTabs
- MagentoBackendTestBlockWidgetGrid
- MagentoUiTestBlockAdminhtmlDataGrid
For better understand go through below reference link.
- Block documentration
- Container documentration
I hope it helps!
add a comment |
I think Block and Container are different entity so there is no need to compare each other.
But here are some functional similarity between each-other.
For Ex: If you want to Extend (change the default behavior) of Block & Container you can use like this.
<referenceContainer name="content"></referenceContainer>
And
<referenceBlock name="product.info.addtocart"></referenceBlock>
A block can have the following features:
- A block can contain other blocks.
- A block can be used in several pages and blocks.
Example
A block MagentoUiTestBlockMessages
extends a basic block MagentoMtfBlockBlock
and implements methods to interact with messages.
Magento contains basic blocks for the functional testing with a logic that you can reuse. The most popular are the following:
- MagentoMtfBlockBlock
- MagentoMtfBlockForm
- MagentoBackendTestBlockWidgetTab
- MagentoBackendTestBlockWidgetFormTabs
- MagentoBackendTestBlockWidgetGrid
- MagentoUiTestBlockAdminhtmlDataGrid
For better understand go through below reference link.
- Block documentration
- Container documentration
I hope it helps!
add a comment |
I think Block and Container are different entity so there is no need to compare each other.
But here are some functional similarity between each-other.
For Ex: If you want to Extend (change the default behavior) of Block & Container you can use like this.
<referenceContainer name="content"></referenceContainer>
And
<referenceBlock name="product.info.addtocart"></referenceBlock>
A block can have the following features:
- A block can contain other blocks.
- A block can be used in several pages and blocks.
Example
A block MagentoUiTestBlockMessages
extends a basic block MagentoMtfBlockBlock
and implements methods to interact with messages.
Magento contains basic blocks for the functional testing with a logic that you can reuse. The most popular are the following:
- MagentoMtfBlockBlock
- MagentoMtfBlockForm
- MagentoBackendTestBlockWidgetTab
- MagentoBackendTestBlockWidgetFormTabs
- MagentoBackendTestBlockWidgetGrid
- MagentoUiTestBlockAdminhtmlDataGrid
For better understand go through below reference link.
- Block documentration
- Container documentration
I hope it helps!
I think Block and Container are different entity so there is no need to compare each other.
But here are some functional similarity between each-other.
For Ex: If you want to Extend (change the default behavior) of Block & Container you can use like this.
<referenceContainer name="content"></referenceContainer>
And
<referenceBlock name="product.info.addtocart"></referenceBlock>
A block can have the following features:
- A block can contain other blocks.
- A block can be used in several pages and blocks.
Example
A block MagentoUiTestBlockMessages
extends a basic block MagentoMtfBlockBlock
and implements methods to interact with messages.
Magento contains basic blocks for the functional testing with a logic that you can reuse. The most popular are the following:
- MagentoMtfBlockBlock
- MagentoMtfBlockForm
- MagentoBackendTestBlockWidgetTab
- MagentoBackendTestBlockWidgetFormTabs
- MagentoBackendTestBlockWidgetGrid
- MagentoUiTestBlockAdminhtmlDataGrid
For better understand go through below reference link.
- Block documentration
- Container documentration
I hope it helps!
answered 2 days ago
Chirag Patel
1,973220
1,973220
add a comment |
add a comment |
Both containers and blocks are basic components of the Magento page structure. Containers make up the framework of a page and they can be either empty or contain child elements: it could be blocks and other containers.
An example of the container and blocks:
<container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
<block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
</container>
According to your question about child elements there is a Before/after attribute both for container and blocks. This attribute sets the order in which blocks and containers are displayed on a page.
More about containers and blocks you can read here.
add a comment |
Both containers and blocks are basic components of the Magento page structure. Containers make up the framework of a page and they can be either empty or contain child elements: it could be blocks and other containers.
An example of the container and blocks:
<container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
<block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
</container>
According to your question about child elements there is a Before/after attribute both for container and blocks. This attribute sets the order in which blocks and containers are displayed on a page.
More about containers and blocks you can read here.
add a comment |
Both containers and blocks are basic components of the Magento page structure. Containers make up the framework of a page and they can be either empty or contain child elements: it could be blocks and other containers.
An example of the container and blocks:
<container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
<block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
</container>
According to your question about child elements there is a Before/after attribute both for container and blocks. This attribute sets the order in which blocks and containers are displayed on a page.
More about containers and blocks you can read here.
Both containers and blocks are basic components of the Magento page structure. Containers make up the framework of a page and they can be either empty or contain child elements: it could be blocks and other containers.
An example of the container and blocks:
<container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
<block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
<block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
</container>
According to your question about child elements there is a Before/after attribute both for container and blocks. This attribute sets the order in which blocks and containers are displayed on a page.
More about containers and blocks you can read here.
answered yesterday
BelVG
514
514
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256478%2fwhat-is-the-functional-difference-of-block-container-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
this might help: magento.stackexchange.com/a/83750/146
– Marius♦
yesterday
Thank you @Marius :)
– Aditya Shah
yesterday