Remove block from layout depends on condition
Clash Royale CLAN TAG#URR8PPP
I want to remove block product.info.addtocart from layout depends on some conditions
magento2 layout addtocart
add a comment |
I want to remove block product.info.addtocart from layout depends on some conditions
magento2 layout addtocart
1
We need more information.
– St3phan
Feb 12 at 13:16
add a comment |
I want to remove block product.info.addtocart from layout depends on some conditions
magento2 layout addtocart
I want to remove block product.info.addtocart from layout depends on some conditions
magento2 layout addtocart
magento2 layout addtocart
edited Feb 12 at 12:54
Shoaib Munir
1,6881626
1,6881626
asked Feb 12 at 12:52
Serhii HavrylchukSerhii Havrylchuk
14011
14011
1
We need more information.
– St3phan
Feb 12 at 13:16
add a comment |
1
We need more information.
– St3phan
Feb 12 at 13:16
1
1
We need more information.
– St3phan
Feb 12 at 13:16
We need more information.
– St3phan
Feb 12 at 13:16
add a comment |
2 Answers
2
active
oldest
votes
You can use ifconfig
on block
<block class=“…” ifconfig=“section/group/field” name=“product.info.addtocart” />
Or you can use helper:
<block name="product.info.addtocart" class="...">
<action method="setTemplate">
<argument name="template" xsi:type="helper" helper=“VendornameModulenameHelperData::method”>
<param name="name">Vendorname_Modulename::data/template.phtml</param>
</argument>
</action>
</block>
The result in both cases it must to be boolean.
If you want to use in other cases, we need more details.
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
add a comment |
You can't remove block based on conditions in layout except system value(ifconfig
) but you can do this from controller.
e.g)
if(here your condition)
$layout = $this->getLayout();
$layout->unsetElement('product.info.addtocart'); //block name
I hope it helps you.
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%2f261435%2fremove-block-from-layout-depends-on-condition%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use ifconfig
on block
<block class=“…” ifconfig=“section/group/field” name=“product.info.addtocart” />
Or you can use helper:
<block name="product.info.addtocart" class="...">
<action method="setTemplate">
<argument name="template" xsi:type="helper" helper=“VendornameModulenameHelperData::method”>
<param name="name">Vendorname_Modulename::data/template.phtml</param>
</argument>
</action>
</block>
The result in both cases it must to be boolean.
If you want to use in other cases, we need more details.
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
add a comment |
You can use ifconfig
on block
<block class=“…” ifconfig=“section/group/field” name=“product.info.addtocart” />
Or you can use helper:
<block name="product.info.addtocart" class="...">
<action method="setTemplate">
<argument name="template" xsi:type="helper" helper=“VendornameModulenameHelperData::method”>
<param name="name">Vendorname_Modulename::data/template.phtml</param>
</argument>
</action>
</block>
The result in both cases it must to be boolean.
If you want to use in other cases, we need more details.
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
add a comment |
You can use ifconfig
on block
<block class=“…” ifconfig=“section/group/field” name=“product.info.addtocart” />
Or you can use helper:
<block name="product.info.addtocart" class="...">
<action method="setTemplate">
<argument name="template" xsi:type="helper" helper=“VendornameModulenameHelperData::method”>
<param name="name">Vendorname_Modulename::data/template.phtml</param>
</argument>
</action>
</block>
The result in both cases it must to be boolean.
If you want to use in other cases, we need more details.
You can use ifconfig
on block
<block class=“…” ifconfig=“section/group/field” name=“product.info.addtocart” />
Or you can use helper:
<block name="product.info.addtocart" class="...">
<action method="setTemplate">
<argument name="template" xsi:type="helper" helper=“VendornameModulenameHelperData::method”>
<param name="name">Vendorname_Modulename::data/template.phtml</param>
</argument>
</action>
</block>
The result in both cases it must to be boolean.
If you want to use in other cases, we need more details.
answered Feb 12 at 13:24
St3phanSt3phan
1,9611136
1,9611136
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
add a comment |
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
With helper worked
– Serhii Havrylchuk
Feb 12 at 13:41
add a comment |
You can't remove block based on conditions in layout except system value(ifconfig
) but you can do this from controller.
e.g)
if(here your condition)
$layout = $this->getLayout();
$layout->unsetElement('product.info.addtocart'); //block name
I hope it helps you.
add a comment |
You can't remove block based on conditions in layout except system value(ifconfig
) but you can do this from controller.
e.g)
if(here your condition)
$layout = $this->getLayout();
$layout->unsetElement('product.info.addtocart'); //block name
I hope it helps you.
add a comment |
You can't remove block based on conditions in layout except system value(ifconfig
) but you can do this from controller.
e.g)
if(here your condition)
$layout = $this->getLayout();
$layout->unsetElement('product.info.addtocart'); //block name
I hope it helps you.
You can't remove block based on conditions in layout except system value(ifconfig
) but you can do this from controller.
e.g)
if(here your condition)
$layout = $this->getLayout();
$layout->unsetElement('product.info.addtocart'); //block name
I hope it helps you.
answered Feb 12 at 13:23
Bilal UseanBilal Usean
4,98923689
4,98923689
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.
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%2f261435%2fremove-block-from-layout-depends-on-condition%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
We need more information.
– St3phan
Feb 12 at 13:16