name = 'categoryimg'; $this->tab = 'front_office_features'; $this->version = '1.0'; parent::__construct(); $this->displayName = $this->l('Category Image'); $this->description = $this->l('Display image category on left column.'); } public function install() { if(!parent::install() OR !$this->registerHook('displayLeftVP')) { return FALSE; } return TRUE; } public function hookdisplayLeftVP($params) { global $smarty; $id_category = $params['id_category']; $id_lang = (int) Tools::getValue('id_lang', Configuration::get('PS_LANG_DEFAULT')); if(file_exists(_PS_ROOT_DIR_.'/img/c/'. $id_category. '.jpg')) { $category = new Category($id_category, $id_lang); }else{ $id_parent = Category::getIdParent($id_category); if(file_exists(_PS_ROOT_DIR_.'/img/c/'. $id_parent. '.jpg')) { $category = new Category($id_parent, $id_lang); }else{ $parent_bis = Category::getIdParent($id_parent); if(file_exists(_PS_ROOT_DIR_.'/img/c/'. $parent_bis. '.jpg')) { $category = new Category($parent_bis, $id_lang); }else{ $category = ""; } } } if ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp_'.$id_lang.'.jpg') && $params['id_category'] != $category->id) { $id_category_thumb = $params['id_category']; } elseif ($category && $id_parent && file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_parent.'_thumb_vp_'.$id_lang.'.jpg') && $id_parent!= $category->id) { $id_category_thumb = $id_parent; } elseif ($category && $parent_bis && file_exists(_PS_ROOT_DIR_.'/img/c/'.$parent_bis.'_thumb_vp_'.$id_lang.'.jpg') && $parent_bis!= $category->id) { $id_category_thumb = $parent_bis; // keeping retrocompatibility } elseif ($category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$params['id_category'].'_thumb_vp.jpg') && $params['id_category'] != $category->id) { $id_category_thumb = $params['id_category']; } elseif ($category && $id_parent && file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_parent.'_thumb_vp.jpg') && $id_parent!= $category->id) { $id_category_thumb = $id_parent; } elseif ($category && $parent_bis && file_exists(_PS_ROOT_DIR_.'/img/c/'.$parent_bis.'_thumb_vp.jpg') && $parent_bis!= $category->id) { $id_category_thumb = $parent_bis; // End retrocompatibility } else { $id_category_thumb = $category->id; } $sale = Sale::getSaleFromCategory(Tools::getValue('id_category')); $smarty->assign('sale', $sale); $smarty->assign('consumable', ((int) _SHOP_PRIVATESALES_CONSUMABLE == (int) $sale->id)? true : false); $smarty->assign('category', $category); $smarty->assign('is_thumb_vp',(file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg'))); $smarty->assign('is_thumb_vp_lang',(file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp_'.$id_lang.'.jpg'))); $smarty->assign('id_category_thumb',$id_category_thumb); return $this->display(__FILE__, 'left_img.tpl'); } }