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?










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























      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



























                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

























                  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













                  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












                  share|improve this answer



                  share|improve this answer










                  answered Mar 19 at 10:22









                  Silky AroraSilky Arora

                  1




                  1



























                      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

                      Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

                      Masuk log Menu navigasi

                      อาณาจักร (ชีววิทยา) ดูเพิ่ม อ้างอิง รายการเลือกการนำทาง10.1086/39456810.5962/bhl.title.447410.1126/science.163.3863.150576276010.1007/BF01796092408502"Phylogenetic structure of the prokaryotic domain: the primary kingdoms"10.1073/pnas.74.11.5088432104270744"Towards a natural system of organisms: proposal for the domains Archaea, Bacteria, and Eucarya"1990PNAS...87.4576W10.1073/pnas.87.12.4576541592112744PubMedJump the queueexpand by handPubMedJump the queueexpand by handPubMedJump the queueexpand by hand"A revised six-kingdom system of life"10.1111/j.1469-185X.1998.tb00030.x9809012"Only six kingdoms of life"10.1098/rspb.2004.2705169172415306349"Kingdoms Protozoa and Chromista and the eozoan root of the eukaryotic tree"10.1098/rsbl.2009.0948288006020031978เพิ่มข้อมูล