1

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; ?>
  • what move element tag are you using? – William Oakley Oct 19 '16 at 16:26
  • <move element="category.description" destination="category.product.list.additional" before="product_list_toolbar" /> – Webninja Oct 19 '16 at 16:30
  • do you have anything else in the catalog_category_view.xml? do you have multiple versions of the xml file? – William Oakley Oct 20 '16 at 10:08
  • No, nothing else there. I don't think that I have multiple versions of it. Where could another version be? – Webninja Oct 20 '16 at 14:09
  • you might have a version in Magento_Catalog and a version in Magento_Theme – William Oakley Oct 20 '16 at 14:19
1

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.

  • This looks like it should work, but still not working. Updated my question. – Webninja Oct 19 '16 at 16:58
  • @Webninja - Try getBlockHtml instead of getChildHtml. Technically it shouldn't make a difference as it is a child anyway but it's worth a try. – Ben Crook Oct 19 '16 at 18:01
  • @Ben - That did the trick! It did not move the description, but it printed it again. Now description appears two times in different locations of the page. Have to remove other one somehow. – Webninja Oct 19 '16 at 18:29
  • For some reason anything I put here: app/design/frontend/{Company}/{Theme}/Magento_Catalog/layout/catalog_category_view.xml has no effect. Tried to remove the description completely with this: <referenceBlock name="category.description" remove="true" /> – Webninja Oct 19 '16 at 18:39
  • Hmmm if that works it sounds like the block isn't actually a child of category.products. Let me see if my Magento 2 box is booting properly, if so I'll put up an answer an example for you. – Ben Crook Oct 19 '16 at 18:40
0

Just add below code in app/design/frontend/{Company}/{Theme}/Magento_Catalog/layout/catalog_category_view.xml file:

<move element="category.description" destination="content" before="-" />

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.