Thursday 28 July 2011

joomla virtuemart - customizing the category page template

Hot on the tails of my last blog joomla virtuemart - where do I control the amount of categories per row that are displayed . My next task was to put a div around the category image that I can control with CSS and to add the description underneath the image.

Which would get it look a bit like this.


The first task of wrapping a div around the image was real easy

OPEN

components/com_virtuemart/themes/default/templates/common/categoryChildlist.tpl.php

UNDER

foreach( $categories as $category ) {
if ($iCol == 1) { // this is an indicator wether a row needs to be opened or not
echo "
\n";
}
?>


< td align="center" width="%" >


is where I started my div - and ended the div before the closing of the table cell < / td > - i called mine < div class="cateforyboxes" >

The next problem of ADDING A DESCRIPTION TO VIRTUEMART JOOMLA CATEGORY PAGE was a bit harder to sort.

OPEN

administrator/components/com_virtuemart/classes/ps_product_category.php

on line 926 find

$q = "SELECT category_id, category_thumb_image, category_child_id,category_name FROM

AND CHANGE TO

$q = "SELECT category_id, catergory_description, category_thumb_image, category_child_id,category_name FROM


THEN FROM LINE 935


while( $db->next_record() ) {
$childs[] = array (
'category_name' => $db->f("category_name"),

'category_id' => $db->f("category_id"),
'category_thumb_image' => $db->f("category_thumb_image"),
'number_of_products' => ps_product_category::products_in_category( $db->f("category_id")),
);




ADD

'category_description' => $db->f("category_description"),

UNDER

'category_name' => $db->f("category_name"),


this works for me on Joomla 1.5.23 with virtuemart 1.1.5

No comments: