Hi,
Please see the site I am developing here: http://bfplantsales.com/stock
Is it possible to display a Product Count next to each category... eg Excavators (4) like It does in the module I am using on the left hand side?? (IceVMCategories)
Thanks
Gareth
nice link. deosn't work.
Sorry, temp domain was removed.. Try the link now!!
Any ideas?
http://bfplantsales.com/stock/
Hi gpullen,
looks like you've already figured this one out.
;D
Can you share the steps you took to change the code so the number of products in the category is displayed ?
What?!!! noooo!! Read the first post again!!
The category module on left hand side is IceVMCategories.. it Does that by default. I want the main bit in the middle of the page to ALSO show product count!!!
Thanks
Hi gpullen,
wasn't clear enough.
OK 2 step process.
STEP 1 : Modify the MODEL
/administrator/components/com_virtuemart/models/category.php @ line 138.
Look for -
if(!empty($childList)){
if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
foreach($childList as $child){
$xrefTable = new TableCategory_medias($db);
// $xrefTable = $this->getTable('category_medias');
$child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
}
}
Change to -
if(!empty($childList)){
if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
foreach($childList as $child){
$xrefTable = new TableCategory_medias($db);
// $xrefTable = $this->getTable('category_medias');
$child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
$categoryModel = VmModel::getModel ('category');
$child->number_of_products = $categoryModel->countProducts ($child->virtuemart_category_id);
}
}
$categoryModel = VmModel::getModel ('category');
$child->number_of_products = $categoryModel->countProducts ($child->virtuemart_category_id);
STEP 2 : Modify the OUTPUT TEMPLATE
/components/com_virtuemart/views/categories/tmpl/default.php @ line 68.
Look for -
// Show Category ?>
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>
</a>
</h2>
</div>
</div>
Change to -
// Show Category ?>
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?> (<?php echo $category->number_of_products ?>)
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>
</a>
</h2>
</div>
</div>
<?php echo $category->category_name ?> (<?php echo $category->number_of_products ?>)
AND THAT"S IT...
did you sort this out? Mark it solved if you have.
Hi Ivus,
Thanks for helping with the code. I had the same problem and implemented your suggestions but they did nothing. Am using virtuemart 2.0.12f and Joomla 2.5.7. Can you help more? Thanks
Hello,
No need to hack the core... please take a look over here: http://forum.virtuemart.net/index.php?topic=102174.0
Regards
Hi bytelord
Thanks for your quick response. I have placed the code exactly where you suggested (components/com_virtuemart/views/category/tmpl) and in the exact location but nothing at all happens.
Any ideas? Am using Joomla 2.5.7 and VM 2.0.12f. Thanks
lets discuss it on the other thread...