Helo again, I change this to VM 1.1.3 and Joomla 1.5.8
In administrator/components/com_virtuemart/classes/ps_product_category.php
add the "untreeCat" function at the end of the class, thanx haselnuss
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat copy lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* @param int $kat
* @param int $container
* rewritten by haselnuss (to use ps_DB class and store the function in ps_product_category.php)
*/
function untreeCat($kat, &$container) {
$db = new ps_DB;
$q = "SELECT category_child_id FROM #__{vm}_category_xref WHERE category_parent_id='$kat'";
$db->query($q);
// if it is a leaf (no data underneath it) then return
if (!$db->num_rows()) {
return;
}
//else append the result, and recurse the function (so to speak)
else
{
while($db->next_record()) {
$container[] = $db->f("category_child_id");
$kat = $db->f("category_child_id");
$this->untreeCat($kat, $container);
}
}
}
and in administrator/components/com_virtuemart/html/shop_browse_queries.php I add detect list categories page. I dont know, why can't detect untree function on product details page.
About line 63 change:
// Filter Products by Category
if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
} elseif( empty( $keyword ) && empty( $manufacturer_id )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}
}
to:
// Filter Products by Category
/*
* Returns an array of the categories ids recursively for a given category
* untreeCat copy lashae (virtuemart forum http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=20837.0)
* rewritten by Creb (to use shop.browse page detection)
*/
if( $category_id ) {
if( !empty( $search_this_category ) && (!empty( $keyword ) || !empty( $manufacturer_id ) )) {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
} elseif( empty( $keyword ) && empty( $manufacturer_id )) {
if ($_GET["page"]=="shop.browse") {
//$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
$kategoriListesi = array();
$ps_product_category->untreeCat($category_id, $kategoriListesi);
$qkat = " `#__{vm}_product_category_xref`.`category_id` IN(".$category_id . ",";
foreach ($kategoriListesi as $kat)
{
$qkat .= $kat . ',';
}
$qkat .= ")";
$qkat = str_replace(',)', ')', $qkat);
$where_clause[] = $qkat;
} else {
$where_clause[] = "`#__{vm}_product_category_xref`.`category_id`=".$category_id;
}
}
}
If we need hide category thumbnails comment line 106 in administrator/components/com_virtuemart/html/shop.browse.php
//$navigation_childlist = $tpl->fetch( 'common/categoryChildlist.tpl.php');
Hope this helps someone.
regards
Creb