How to give condition in xml file for showing different block in different pagesfooter 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?

What (if any) is the reason to buy in small local stores?

Why is "la Gestapo" feminine?

Air travel with refrigerated insulin

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

How to preserve electronics (computers, ipads, phones) for hundreds of years?

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

Highest stage count that are used one right after the other?

Sort with assumptions

Why is participating in the European Parliamentary elections used as a threat?

Non-Borel set in arbitrary metric space

How to test the sharpness of a knife?

Capacitor electron flow

Turning a hard to access nut?

Unfrosted light bulb

Is there a distance limit for minecart tracks?

Pre-Employment Background Check With Consent For Future Checks

categorizing a variable turns it from insignificant to significant

Showing mass murder in a kid's book

Can you describe someone as luxurious? As in someone who likes luxurious things?

Would a primitive species be able to learn English from reading books alone?

Is there any common country to visit for persons holding UK and Schengen visas?

Friend wants my recommendation but I don't want to give it to him

How can a new country break out from a developed country without war?

Why can't I get pgrep output right to variable on bash script?



How to give condition in xml file for showing different block in different pages


footer 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?













0















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










share|improve this question
























  • 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















0















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










share|improve this question
























  • 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













0












0








0


0






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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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










2 Answers
2






active

oldest

votes


















1














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.






share|improve this answer
































    0














    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.






    share|improve this answer








    New contributor




    Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.



















      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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.






      share|improve this answer





























        1














        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.






        share|improve this answer



























          1












          1








          1







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 15 '18 at 4:44

























          answered Sep 10 '18 at 12:42









          M.SumanM.Suman

          5711




          5711























              0














              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.






              share|improve this answer








              New contributor




              Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                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.






                share|improve this answer








                New contributor




                Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  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.






                  share|improve this answer








                  New contributor




                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  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.







                  share|improve this answer








                  New contributor




                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 18 hours ago









                  Silky AroraSilky Arora

                  1




                  1




                  New contributor




                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Silky Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Sum ergo cogito? 1 nng

                      三茅街道4182Guuntc Dn precexpngmageondP