Magento – Magento 2: How to move category description to main column

categorycategory-descriptionmagento2xml

How can I move the category description from top of the page into main column of the category page just above product list toolbar?

I guess it should be doable by extending the catalog_category_view.xml in

app/design/frontend/{Company}/{Theme}/Magento_Catalog/layout

but for some reason I can't manage to do that with move element tag.

I have this in my

app/design/frontend/{Company}/{Theme}/Magento_Catalog/layout/catalog_category_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>  
      <move element="category.description" destination="category.products" />
  </body>
</page>

And this in my

app/design/frontend/{Company}/{Theme}/Magento_Catalog/templates/category/products.phtml

<?php echo $block->getChildHtml('category.description'); ?>
<?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
   <?php echo $block->getProductListHtml() ?>
<?php endif; ?>

Best Answer

Personally I did it this way:

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

And then inside:

Magento_Catalog/templates/category/image.phtml

Called:

<?php echo $block->getChildHtml('category.description'); ?>

Because I wanted it inside the image, but you could put it just below instead.

I'm sure there's a better way but can't check atm.

Related Topic