VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on June 23, 2012, 11:12:32 AM

Title: All categories at the top when category id=0
Post by: balai on June 23, 2012, 11:12:32 AM
Hi

I m loading the category layout in my Custom Filters extennsion for displaying the filtering results.

The problem is that when there is no category id in the URL's query it displays all the categories at the top.
For example if you try option=com_virtuemart&view=category&virtuemart_category_id=0 , all the categories are displayed.

Can we fix/improve that, to display the children categories only when there is a parent selected?
Title: Re: All categories at the top when category id=0
Post by: Milbo on July 05, 2012, 10:21:39 AM
The parent of all categories is the 0,

But when you mean the products, then you must use the categories view, which is only displaying categories, but no products.
Title: Re: All categories at the top when category id=0
Post by: balai on July 05, 2012, 10:53:39 AM
It wouldn't be more correct to display categories there only when there is a category selected with an id higher to zero?

Otherwise what's the point of having all the categories displayed there?
Title: Re: All categories at the top when category id=0
Post by: Milbo on July 05, 2012, 18:14:17 PM
To have all categories displayed there?

What should else happen when you enter category_id=0 ?
Title: Re: All categories at the top when category id=0
Post by: balai on July 06, 2012, 11:12:25 AM
Category id = 0 means that no category is selected. So children categories cannot be displayed when there is nothing selected.

Replacing the code in the line 60 of the  components\com_virtuemart\views\category\tmpl\default.php, with the following, it does the trick:
if ( VmConfig::get('showCategory',1) and empty($this->keyword) and  $this->category->virtuemart_category_id>0)
Title: Re: All categories at the top when category id=0
Post by: Milbo on July 06, 2012, 13:38:08 PM
no, this is just wrong

category_id 0 means, get all categories beyond 0. No category selected would be !isset or ===null. Not 0. I hope you know that in php null != 0 != "0" != ""