How to give condition in xml file for showing different block in different pages The Next CEO of Stack Overflowfooter links multilingualCan I made a full-width block before the footer on a 2columns-left page?What are all the allowed `xsi:type` values in the xml's from Magento2How do I discover the XML Layout name for a page?Add a static block through xml to a specific cms_page?How to get the newsletter subscriber box and show the custom Module in Magento 2Open footer block link in new tab/windowadd phtml file in every cms pageCustom setting Option for magento admin panelHow can I add a footer block to all the pages?
How exploitable/balanced is this homebrew spell: Spell Permenancy?
Raspberry pi 3 B with Ubuntu 18.04 server arm64: what chip
Plausibility of squid whales
My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?
subequations: How to continue numbering within subequation?
How to implement Comparable so it is consistent with identity-equality?
How dangerous is XSS
How to find out why iTerm2 suddenly wants to access my Calendar?
Horror film about a man brought out of cryogenic suspension without a soul, around 1990
Can you teleport closer to a creature you are Frightened of?
Noise during hard braking
Free fall ellipse or parabola?
Why are time dilation and length contraction needed to fix time?
Subtracting numbers from adjacent columns and successive rows using awk
Is there an equivalent of cd - for cp or mv
What is Decreasing Arithmetic progression?
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
What does this strange code stamp on my passport mean?
Fastest algorithm to decide whether a (always halting) TM accepts a general string
Does the direction of correlation matter for Instrumental Variable?
Defamation due to breach of confidentiality
Can I use UPS to send my tax returns from abroad to IRS Austin?
Is it correct to say moon starry nights?
Is it possible to create a QR code using text?
How to give condition in xml file for showing different block in different pages
The Next CEO of Stack Overflowfooter links multilingualCan I made a full-width block before the footer on a 2columns-left page?What are all the allowed `xsi:type` values in the xml's from Magento2How do I discover the XML Layout name for a page?Add a static block through xml to a specific cms_page?How to get the newsletter subscriber box and show the custom Module in Magento 2Open footer block link in new tab/windowadd phtml file in every cms pageCustom setting Option for magento admin panelHow can I add a footer block to all the pages?
How to give condition in xml file for showing different block in different pages. Like I place a block name "Footer Block" in default xml file, and I want different footer for different pages.
<referenceContainer name="footer">
<block class="MagentoCmsBlockBlock" name="footer_links_block">
<arguments>
<argument name="block_id" xsi:type="string">footer_links_block</argument>
</arguments>
</block>
</referenceContainer>
I want this that this footer only will show in home page and I want to different footer block for other pages. How I can do it in Magento 2.2.5
Thank You
xml magento-2.2.5 footer
add a comment |
How to give condition in xml file for showing different block in different pages. Like I place a block name "Footer Block" in default xml file, and I want different footer for different pages.
<referenceContainer name="footer">
<block class="MagentoCmsBlockBlock" name="footer_links_block">
<arguments>
<argument name="block_id" xsi:type="string">footer_links_block</argument>
</arguments>
</block>
</referenceContainer>
I want this that this footer only will show in home page and I want to different footer block for other pages. How I can do it in Magento 2.2.5
Thank You
xml magento-2.2.5 footer
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32
add a comment |
How to give condition in xml file for showing different block in different pages. Like I place a block name "Footer Block" in default xml file, and I want different footer for different pages.
<referenceContainer name="footer">
<block class="MagentoCmsBlockBlock" name="footer_links_block">
<arguments>
<argument name="block_id" xsi:type="string">footer_links_block</argument>
</arguments>
</block>
</referenceContainer>
I want this that this footer only will show in home page and I want to different footer block for other pages. How I can do it in Magento 2.2.5
Thank You
xml magento-2.2.5 footer
How to give condition in xml file for showing different block in different pages. Like I place a block name "Footer Block" in default xml file, and I want different footer for different pages.
<referenceContainer name="footer">
<block class="MagentoCmsBlockBlock" name="footer_links_block">
<arguments>
<argument name="block_id" xsi:type="string">footer_links_block</argument>
</arguments>
</block>
</referenceContainer>
I want this that this footer only will show in home page and I want to different footer block for other pages. How I can do it in Magento 2.2.5
Thank You
xml magento-2.2.5 footer
xml magento-2.2.5 footer
edited Sep 8 '18 at 7:11
M.Suman
asked Sep 7 '18 at 14:37
M.SumanM.Suman
5711
5711
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32
add a comment |
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32
add a comment |
2 Answers
2
active
oldest
votes
Okay, I got the solution.
I call the .phtml page into .xml file, like this.
default.xml
<referenceContainer name="footer">
<container name="footer-custom" htmlTag="div" htmlClass="footer-custom">
<block class="MagentoFrameworkViewElementTemplate" name="footer_upper" template="Magento_Theme::html/footer.phtml">
</block>
</container>
</referenceContainer>
and then in .phtml file I place the condition and fetch the block there, like this.
footer.phtml
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cmsPage = $objectManager->get('MagentoCmsModelPage');
$cmsIdent = $cmsPage->getIdentifier();
?>
<?php
if ($cmsIdent == 'home')
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block')
->toHtml();
else
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block_for_others')
->toHtml();
?>
It works perfect for me. Thank you.
add a comment |
If you have to show it only for home page, then more appropriate solution will be to show them via cms_index_index.xml. In that way, you can manage everything via XML too including containers if you have to add them in near future.
add a comment |
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%2f241350%2fhow-to-give-condition-in-xml-file-for-showing-different-block-in-different-pages%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
Okay, I got the solution.
I call the .phtml page into .xml file, like this.
default.xml
<referenceContainer name="footer">
<container name="footer-custom" htmlTag="div" htmlClass="footer-custom">
<block class="MagentoFrameworkViewElementTemplate" name="footer_upper" template="Magento_Theme::html/footer.phtml">
</block>
</container>
</referenceContainer>
and then in .phtml file I place the condition and fetch the block there, like this.
footer.phtml
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cmsPage = $objectManager->get('MagentoCmsModelPage');
$cmsIdent = $cmsPage->getIdentifier();
?>
<?php
if ($cmsIdent == 'home')
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block')
->toHtml();
else
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block_for_others')
->toHtml();
?>
It works perfect for me. Thank you.
add a comment |
Okay, I got the solution.
I call the .phtml page into .xml file, like this.
default.xml
<referenceContainer name="footer">
<container name="footer-custom" htmlTag="div" htmlClass="footer-custom">
<block class="MagentoFrameworkViewElementTemplate" name="footer_upper" template="Magento_Theme::html/footer.phtml">
</block>
</container>
</referenceContainer>
and then in .phtml file I place the condition and fetch the block there, like this.
footer.phtml
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cmsPage = $objectManager->get('MagentoCmsModelPage');
$cmsIdent = $cmsPage->getIdentifier();
?>
<?php
if ($cmsIdent == 'home')
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block')
->toHtml();
else
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block_for_others')
->toHtml();
?>
It works perfect for me. Thank you.
add a comment |
Okay, I got the solution.
I call the .phtml page into .xml file, like this.
default.xml
<referenceContainer name="footer">
<container name="footer-custom" htmlTag="div" htmlClass="footer-custom">
<block class="MagentoFrameworkViewElementTemplate" name="footer_upper" template="Magento_Theme::html/footer.phtml">
</block>
</container>
</referenceContainer>
and then in .phtml file I place the condition and fetch the block there, like this.
footer.phtml
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cmsPage = $objectManager->get('MagentoCmsModelPage');
$cmsIdent = $cmsPage->getIdentifier();
?>
<?php
if ($cmsIdent == 'home')
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block')
->toHtml();
else
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block_for_others')
->toHtml();
?>
It works perfect for me. Thank you.
Okay, I got the solution.
I call the .phtml page into .xml file, like this.
default.xml
<referenceContainer name="footer">
<container name="footer-custom" htmlTag="div" htmlClass="footer-custom">
<block class="MagentoFrameworkViewElementTemplate" name="footer_upper" template="Magento_Theme::html/footer.phtml">
</block>
</container>
</referenceContainer>
and then in .phtml file I place the condition and fetch the block there, like this.
footer.phtml
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cmsPage = $objectManager->get('MagentoCmsModelPage');
$cmsIdent = $cmsPage->getIdentifier();
?>
<?php
if ($cmsIdent == 'home')
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block')
->toHtml();
else
echo $block->getLayout()
->createBlock('MagentoCmsBlockBlock')
->setBlockId('footer_links_block_for_others')
->toHtml();
?>
It works perfect for me. Thank you.
edited Sep 15 '18 at 4:44
answered Sep 10 '18 at 12:42
M.SumanM.Suman
5711
5711
add a comment |
add a comment |
If you have to show it only for home page, then more appropriate solution will be to show them via cms_index_index.xml. In that way, you can manage everything via XML too including containers if you have to add them in near future.
add a comment |
If you have to show it only for home page, then more appropriate solution will be to show them via cms_index_index.xml. In that way, you can manage everything via XML too including containers if you have to add them in near future.
add a comment |
If you have to show it only for home page, then more appropriate solution will be to show them via cms_index_index.xml. In that way, you can manage everything via XML too including containers if you have to add them in near future.
If you have to show it only for home page, then more appropriate solution will be to show them via cms_index_index.xml. In that way, you can manage everything via XML too including containers if you have to add them in near future.
answered Mar 19 at 10:22
Silky AroraSilky Arora
1
1
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%2f241350%2fhow-to-give-condition-in-xml-file-for-showing-different-block-in-different-pages%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
Please clarify, by different pages you mean different type of pages or like different category pages/ different product pages?
– Vivek Kumar
Sep 7 '18 at 14:58
I want to show footer in home page and different footer for other pages. And this footer section I have done by block. In default.xml file I fetch this block. So I want any condition that I can differentiate in xml file. How I can do this. Thank you for your reply.
– M.Suman
Sep 8 '18 at 7:04
Hello @Vivek Kumar, is there any way to do this functionality? Sorry, that before I didn't clarify the question clearly. Please help, if is there any way to do this. Thank you.
– M.Suman
Sep 10 '18 at 7:32