1. Go to your modules folder and make a copy/duplicate of your blockcategories folder and rename it with blockcategories2 for example. 2. Enter in the blockcategories2 folder and rename the blockcategories.tpl and blockcategories.php to blockcategories2.tpl and blockcategories2.php. 3. Open up your blockcategories2.php and replace all blockcategories words to blockcategories2. 4. in blockcategories2.php replace hookLeftColumn method with:
public function hookLeftColumn($params)
{
global $smarty, $cookie;
$id_customer = (int)($params['cookie']->id_customer);
$id_group = $id_customer ? Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_product = (int)(Tools::getValue('id_product', 0));
$id_category = (int)(Tools::getValue('id_category', 0));
$id_lang = (int)($params['cookie']->id_lang);
$smartyCacheId = 'blockcategories2|'.$id_group.'_'.$id_lang.'_'.$id_product.'_'.$id_category;
if($id_category)
$category = new CategoryCore($id_category,$id_lang);
else
$category = Category::getRootCategory ($id_lang);
$id_category = $category->id;
Tools::enableCache();
if (!$this->isCached('blockcategories2.tpl', $smartyCacheId))
{
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.id_parent, c.id_category,c.nleft,c.nright, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
AND cg.`id_group` = '.$id_group.'
AND c.nleft >= '.$category->nleft.'
AND c.nright <= '.$category->nright.'
ORDER BY `level_depth` ASC, c.`position` ASC')
)
return;
$resultParents = array();
$resultIds = array();
foreach ($result as &$row)
{
$resultParents[$row['id_parent']][] = &$row;
$resultIds[$row['id_category']] = &$row;
}
$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'),$id_category);
unset($resultParents);
unset($resultIds);
$isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);
if (Tools::isSubmit('id_category'))
{
$cookie->last_visited_category = $id_category;
$smarty->assign('currentCategoryId', $cookie->last_visited_category);
}
if (Tools::isSubmit('id_product'))
{
if (!isset($cookie->last_visited_category) OR !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $cookie->last_visited_category))))
{
$product = new Product($id_product);
if (isset($product) AND Validate::isLoadedObject($product))
$cookie->last_visited_category = (int)($product->id_category_default);
}
$smarty->assign('currentCategoryId', (int)($cookie->last_visited_category));
}
$smarty->assign('blockCategTree', $blockCategTree);
if (file_exists(_PS_THEME_DIR_.'modules/blockcategories2/blockcategories2.tpl'))
$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategories2/category-tree-branch.tpl');
else
$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories2/category-tree-branch.tpl');
$smarty->assign('isDhtml', $isDhtml);
}
$smarty->cache_lifetime = 31536000; // 1 Year
$display = $this->display(__FILE__, 'blockcategories2.tpl', $smartyCacheId);
Tools::restoreCacheSettings();
return $display;
}
Credits: steps 1, 2 and 3 come from Dharani's Blog