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

                      Masuk log Menu navigasi

                      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

                      Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области