I'm trying to move the category image and description into a single div.

They're both in the catalog module under view/frontend/layout/catalog_category_view.xml

 <referenceContainer name="columns.top">
            <container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
                <block class="Magento\Catalog\Block\Category\View" name="category.image" template="Magento_Catalog::category/image.phtml">
                        <argument name="image" xsi:type="object">Magento\Catalog\ViewModel\Category\Image</argument>
                        <argument name="output" xsi:type="object">Magento\Catalog\ViewModel\Category\Output</argument>
                <block class="Magento\Catalog\Block\Category\View" name="category.description" template="Magento_Catalog::category/description.phtml"/>
                <block class="Magento\Catalog\Block\Category\View" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>

This is my code

<move element="category.description" destination="category.view.container" before="category.image" />

Nothing is happening

  • Have you checked my answer?
    – ZealousWeb
    Apr 21 '21 at 12:21

As per default magento code category image and description is already in a single div which is "category-view". Both are calling in the same container. According to your "move element" code , it seems you are trying move description before category image and that will be achieve by below code.

In your theme's or module's catalog_category_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <move element="category.description" destination="category.view.container" before="-" />

Please check and let me know if you have any query.

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.