magento 2 add static block on category page left sidebar only












1















I have override Module-Catalog into my theme's folder.



I want to add custom blocks in category sidebar. so in catalog_category_View.xml file i have added following code which works if i put it in default.xml file but it doesn't work for catalog_category_view.xml file.



<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="sidebar.additional">
<block class="MagentoCmsBlockBlock" name="top_left_sidebar">
<arguments>
<argument name="block_id" xsi:type="string">top_left_sidebar</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>


I want to show that block for category page left column only. How can i do that?










share|improve this question





























    1















    I have override Module-Catalog into my theme's folder.



    I want to add custom blocks in category sidebar. so in catalog_category_View.xml file i have added following code which works if i put it in default.xml file but it doesn't work for catalog_category_view.xml file.



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceContainer name="sidebar.additional">
    <block class="MagentoCmsBlockBlock" name="top_left_sidebar">
    <arguments>
    <argument name="block_id" xsi:type="string">top_left_sidebar</argument>
    </arguments>
    </block>
    </referenceContainer>
    </body>
    </page>


    I want to show that block for category page left column only. How can i do that?










    share|improve this question



























      1












      1








      1








      I have override Module-Catalog into my theme's folder.



      I want to add custom blocks in category sidebar. so in catalog_category_View.xml file i have added following code which works if i put it in default.xml file but it doesn't work for catalog_category_view.xml file.



      <?xml version="1.0"?>
      <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body>
      <referenceContainer name="sidebar.additional">
      <block class="MagentoCmsBlockBlock" name="top_left_sidebar">
      <arguments>
      <argument name="block_id" xsi:type="string">top_left_sidebar</argument>
      </arguments>
      </block>
      </referenceContainer>
      </body>
      </page>


      I want to show that block for category page left column only. How can i do that?










      share|improve this question
















      I have override Module-Catalog into my theme's folder.



      I want to add custom blocks in category sidebar. so in catalog_category_View.xml file i have added following code which works if i put it in default.xml file but it doesn't work for catalog_category_view.xml file.



      <?xml version="1.0"?>
      <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body>
      <referenceContainer name="sidebar.additional">
      <block class="MagentoCmsBlockBlock" name="top_left_sidebar">
      <arguments>
      <argument name="block_id" xsi:type="string">top_left_sidebar</argument>
      </arguments>
      </block>
      </referenceContainer>
      </body>
      </page>


      I want to show that block for category page left column only. How can i do that?







      magento2 magento-2.1 category layout xml






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '17 at 7:57









      Nero Phung

      8341420




      8341420










      asked Nov 15 '17 at 6:37









      jackjack

      456719




      456719






















          3 Answers
          3






          active

          oldest

          votes


















          0














          First ensure that layout file name catalog_category_view.xml v should be lowercase instead of Uppercase.



          If it is not worked then changes the referenceContainer name to sidebar.main from sidebar.additional.



          Or can do by Widget



          Goto admin >Content>Widget . Create a new widget



          On this widget select



          Type: CMS STATIC BLOCK



          Layout Updates:




          • Display On:Anchor Categories and All Categories

          • Display On:Non-Anchor Categories and All Categories


          enter image description here



          and on Widget Options tab select your cms static.



          This is best solution






          share|improve this answer


























          • Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

            – jack
            Nov 15 '17 at 10:06



















          0














          Instead on catalog_category_view.xml use catalog_category_view_type_layered.xml to add the container you want to use for the widget






          share|improve this answer































            0














            You don't have to edit your xml files. Just add a cms block to your design layout.



            In your Magento Backend go to the category>design
            insert into the xml layout update area



            <referenceContainer name="sidebar.main">
            <block class="MagentoCmsBlockBlock" name="Your_CMS_Block">
            <arguments>
            <argument name="block_id" xsi:type="string">Your_CMS_Block</argument>
            </arguments>
            </block>
            </referenceContainer>


            I always use the same name for both the cms block name and the identifier when I create the block.



            The only reason I'd edit the XML for this is if you are building this shop for a client and you don't want them to be able to go in and change what you did.






            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%2f201583%2fmagento-2-add-static-block-on-category-page-left-sidebar-only%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              First ensure that layout file name catalog_category_view.xml v should be lowercase instead of Uppercase.



              If it is not worked then changes the referenceContainer name to sidebar.main from sidebar.additional.



              Or can do by Widget



              Goto admin >Content>Widget . Create a new widget



              On this widget select



              Type: CMS STATIC BLOCK



              Layout Updates:




              • Display On:Anchor Categories and All Categories

              • Display On:Non-Anchor Categories and All Categories


              enter image description here



              and on Widget Options tab select your cms static.



              This is best solution






              share|improve this answer


























              • Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

                – jack
                Nov 15 '17 at 10:06
















              0














              First ensure that layout file name catalog_category_view.xml v should be lowercase instead of Uppercase.



              If it is not worked then changes the referenceContainer name to sidebar.main from sidebar.additional.



              Or can do by Widget



              Goto admin >Content>Widget . Create a new widget



              On this widget select



              Type: CMS STATIC BLOCK



              Layout Updates:




              • Display On:Anchor Categories and All Categories

              • Display On:Non-Anchor Categories and All Categories


              enter image description here



              and on Widget Options tab select your cms static.



              This is best solution






              share|improve this answer


























              • Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

                – jack
                Nov 15 '17 at 10:06














              0












              0








              0







              First ensure that layout file name catalog_category_view.xml v should be lowercase instead of Uppercase.



              If it is not worked then changes the referenceContainer name to sidebar.main from sidebar.additional.



              Or can do by Widget



              Goto admin >Content>Widget . Create a new widget



              On this widget select



              Type: CMS STATIC BLOCK



              Layout Updates:




              • Display On:Anchor Categories and All Categories

              • Display On:Non-Anchor Categories and All Categories


              enter image description here



              and on Widget Options tab select your cms static.



              This is best solution






              share|improve this answer















              First ensure that layout file name catalog_category_view.xml v should be lowercase instead of Uppercase.



              If it is not worked then changes the referenceContainer name to sidebar.main from sidebar.additional.



              Or can do by Widget



              Goto admin >Content>Widget . Create a new widget



              On this widget select



              Type: CMS STATIC BLOCK



              Layout Updates:




              • Display On:Anchor Categories and All Categories

              • Display On:Non-Anchor Categories and All Categories


              enter image description here



              and on Widget Options tab select your cms static.



              This is best solution







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 15 '17 at 7:25

























              answered Nov 15 '17 at 7:16









              Amit BeraAmit Bera

              57.6k1474172




              57.6k1474172













              • Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

                – jack
                Nov 15 '17 at 10:06



















              • Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

                – jack
                Nov 15 '17 at 10:06

















              Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

              – jack
              Nov 15 '17 at 10:06





              Thanks amit for your answer. catalog_category_view.xml name in lower case. Yes i know can be added from admin but in my module if i want to add it through <referenceContainer > then it doesn't work. I did try sidebar.main and sidebar.additional but not working. Did check vendor file and if i add that code in that file it works. As we should not edit vendor file we have rewritten this file in my custom theme folder and adding <referenceContainer name="sidebar.addition"> but not working. What could be the issue?

              – jack
              Nov 15 '17 at 10:06













              0














              Instead on catalog_category_view.xml use catalog_category_view_type_layered.xml to add the container you want to use for the widget






              share|improve this answer




























                0














                Instead on catalog_category_view.xml use catalog_category_view_type_layered.xml to add the container you want to use for the widget






                share|improve this answer


























                  0












                  0








                  0







                  Instead on catalog_category_view.xml use catalog_category_view_type_layered.xml to add the container you want to use for the widget






                  share|improve this answer













                  Instead on catalog_category_view.xml use catalog_category_view_type_layered.xml to add the container you want to use for the widget







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 14 '18 at 13:25









                  Klaas van der WeijKlaas van der Weij

                  165110




                  165110























                      0














                      You don't have to edit your xml files. Just add a cms block to your design layout.



                      In your Magento Backend go to the category>design
                      insert into the xml layout update area



                      <referenceContainer name="sidebar.main">
                      <block class="MagentoCmsBlockBlock" name="Your_CMS_Block">
                      <arguments>
                      <argument name="block_id" xsi:type="string">Your_CMS_Block</argument>
                      </arguments>
                      </block>
                      </referenceContainer>


                      I always use the same name for both the cms block name and the identifier when I create the block.



                      The only reason I'd edit the XML for this is if you are building this shop for a client and you don't want them to be able to go in and change what you did.






                      share|improve this answer






























                        0














                        You don't have to edit your xml files. Just add a cms block to your design layout.



                        In your Magento Backend go to the category>design
                        insert into the xml layout update area



                        <referenceContainer name="sidebar.main">
                        <block class="MagentoCmsBlockBlock" name="Your_CMS_Block">
                        <arguments>
                        <argument name="block_id" xsi:type="string">Your_CMS_Block</argument>
                        </arguments>
                        </block>
                        </referenceContainer>


                        I always use the same name for both the cms block name and the identifier when I create the block.



                        The only reason I'd edit the XML for this is if you are building this shop for a client and you don't want them to be able to go in and change what you did.






                        share|improve this answer




























                          0












                          0








                          0







                          You don't have to edit your xml files. Just add a cms block to your design layout.



                          In your Magento Backend go to the category>design
                          insert into the xml layout update area



                          <referenceContainer name="sidebar.main">
                          <block class="MagentoCmsBlockBlock" name="Your_CMS_Block">
                          <arguments>
                          <argument name="block_id" xsi:type="string">Your_CMS_Block</argument>
                          </arguments>
                          </block>
                          </referenceContainer>


                          I always use the same name for both the cms block name and the identifier when I create the block.



                          The only reason I'd edit the XML for this is if you are building this shop for a client and you don't want them to be able to go in and change what you did.






                          share|improve this answer















                          You don't have to edit your xml files. Just add a cms block to your design layout.



                          In your Magento Backend go to the category>design
                          insert into the xml layout update area



                          <referenceContainer name="sidebar.main">
                          <block class="MagentoCmsBlockBlock" name="Your_CMS_Block">
                          <arguments>
                          <argument name="block_id" xsi:type="string">Your_CMS_Block</argument>
                          </arguments>
                          </block>
                          </referenceContainer>


                          I always use the same name for both the cms block name and the identifier when I create the block.



                          The only reason I'd edit the XML for this is if you are building this shop for a client and you don't want them to be able to go in and change what you did.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 13 mins ago









                          divya sekar

                          135




                          135










                          answered Dec 26 '18 at 7:43









                          JadeMageJadeMage

                          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%2f201583%2fmagento-2-add-static-block-on-category-page-left-sidebar-only%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

                              Last logged in always never, not logging

                              Colouring column values based on a specific condition. How could I do this?

                              Iĥnotaksono