1

I have a CMS Page with '2 Column Right' layout. I want to add 'My Cart','Compare Products','Newsletter' Sidebars in right column.

http://i.prntscr.com/eb303e17180d467dbc80b942cd3076ee.png

How is it possible?

2

Add this code in design tab of cms page:

<referenceContainer name="sidebar.additional">
        <!-- Compare Block -->
        <block class="Magento\Framework\View\Element\Template" name="catalog.compare.sidebar"
               template="Magento_Catalog::product/compare/sidebar.phtml">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="compareProducts" xsi:type="array">
                            <item name="component" xsi:type="string">Magento_Catalog/js/view/compare-products</item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </block>
        <!-- Newsletter Block -->
        <block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe" as="subscribe" before="-" template="subscribe.phtml"/>

    </referenceContainer>

However I am not sure how you can add the "My Cart" block.

This code will just add the blocks. If you wish to add Title and extra text to the blocks use this code instead in the content tab of cms page.

<div class="block widget block-compare">
    <div class="block-title">
        <strong role="heading">Compare Products</strong>
    </div>
    {{block class="Magento\Framework\View\Element\Template" name="catalog.compare.sidebar" template="Magento_Catalog::product/compare/sidebar.phtml" /}}
</div>      
<div class="block widget block-newsletter">
    <div class="block-title">
        <strong role="heading">Newsletter</strong>
    </div>
    {{block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe" as="subscribe" before="-" template="subscribe.phtml"/}}
</div>

UPDATE:

You can create a static block say 'test' in the Admin. Add this code:

 {{block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe" template="subscribe.phtml"/}}

Create a widget. Go to Content >> Widgets Add layout update to the page you wish to add this block to and set the container to Sidebar Additional.

4
  • Used the layout code, Compare sidebar is working now. But newsletter is not May 29 '17 at 9:15
  • @Jancy Abraham check my updated answer.
    – Sejal Shah
    May 29 '17 at 11:59
  • @Jancy did u check my updated answer ?
    – Sejal Shah
    Jun 3 '17 at 13:59
  • I want to display it in a specified CMS page(Only one). It is possible in Widgets layout Jun 5 '17 at 4:38

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.