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="Magento\Cms\Block\Block" 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?

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

  • 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

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="Magento\Cms\Block\Block" 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.