i want to add another category description section after the product listing on category view page.
Is it possible without coding in Magento 2.2? If not how can i put it?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityi want to add another category description section after the product listing on category view page.
Is it possible without coding in Magento 2.2? If not how can i put it?
This is not possible to do from the admin. You have to create an XML file to get this working. There are a few different ways to do this, but i will show you the way using a custom theme. Create a file here:
app/design/frontend/{vendor_namespace}/{theme_name}/Magento_Catalog/layout/catalog_category_view.xml
And use this code here:
<?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">
<body>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Category\View" name="category.description.bottom" template="Magento_Catalog::category/description.phtml" after="-"/>
</referenceContainer>
</body>
</page>
This will place the secondary category description at the bottom of the content of the page. This might not be the right place for you, but you can play with the referenceContainer
you are looking to place this in and get the results you are looking for.
After more information, if you are looking to place the same content at the bottom of all categories you can use a Widget to do this. Create a Block in the admin under Content -> Blocks
with the info that you want. Then create a new Widget under Content -> Widgets
. Inside here you have to link this new widget to the theme you are using and give it a name. This can't be changed down the line, so if you have multiple themes you will need to make a widget for each.
Inside here you set the required field and choose the location of where you want the widget to go.
In the other tab you can select the Block you created earlier. Now this block will show up at the bottom of every category on the site.
There is a little "hack" that you can use if you just want content on just one category. You can create a xml file that is locked to just one id and place your call to a template (or cms block if you like) there.
app/design/frontend/{vendor_namespace}/{theme_name}/Magento_Catalog/layout/catalog_category_view_id_20.xml
With this in place, you can now make any calls you like and it will only show on that category.
<?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">
<body>
<referenceContainer name="content">
<!--calling a template file-->
<block class="Magento\Catalog\Block\Category\View" name="single.category.description.bottom" template="Magento_Catalog::category/cat-specific-description.phtml" after="-"/>
<!--or calling a cms block in from the admin -->
<block class="Magento\Cms\Block\Block" name="your_block">
<arguments>
<argument name="block_id" xsi:type="string">your_block_name_here</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>