2

In Magento 2, I want add a new container right.sidebar under <body> directly, not under content container. Then move the block catalog.product.related to the new container. I write the codes below in my custom catalog_product_view.xml, but it doesn't work. Thanks for any advice :)

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <container name="right.sidebar" />
        <move element="catalog.product.related" destination="right.sidebar" />
    </body>
</page>
3

In container tag there you must have a attribute

htmlTag

So you XML should be like :

<container name="right.sidebar" htmlTag="div" htmlClass="right-sidebar" />

You can use htmlClass for applying any CSS class so that you can apply your css to it and before/after attribute to define it's place in page.

Note : class name should not contain dot(.) or # because it's css and is selectors.

I have tested your code with my modification (after adding htmlTag attribute) it's working fine.

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.