VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: barbara on October 16, 2021, 20:40:44 PM

Title: Display category description in categories with no products
Post by: barbara on October 16, 2021, 20:40:44 PM
Hi
I`m sure this is an easy fix, but I cant seem to find it.

I have several categories which do not have products in them - but I would like the category description to load when the category is selected.

right now if i click on a category which has no products from the categories browse page the category page url loads, but there is no description for the category.

As soon as I add a product the description loads.

Any help getting the description to load without active products would be greatly appreciated.
Title: Re: Display category description in categories with no products
Post by: GJC Web Design on October 16, 2021, 22:08:56 PM
standard template?

try removing the

if(!empty($this->category)) {

line 56  components\com_virtuemart\views\category\tmpl\default.php
Title: Re: Display category description in categories with no products
Post by: vmfyelloq19 on November 09, 2021, 11:30:33 AM
- Make a template override for com_virtuemart (never edit core files as you will loose any changes on next update)
- Edit .../htdocs/templates/[yourtemplate]/html/com_virtuemart/category/default.php
- Look for if (!empty($this->products)) around line 167
- Look for the corresponding line } elseif ($this->keyword !== false) { around line 182
- Before or after the following line echo vmText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
add
echo '<div class"category-description no-products">' . $this->category->category_description . '</div>';
(Use $this->category->category_name if you want that too)
- In your template's CSS file use .category-description.no-products { [your css declarations] } if required

Title: Re: Display category description in categories with no products
Post by: barbara on November 15, 2021, 18:05:05 PM
thank you!!!