60 lines
1.9 KiB
PHP
Executable File
60 lines
1.9 KiB
PHP
Executable File
<?php
|
|
class CategoryImg extends Module {
|
|
public function __construct() {
|
|
$this->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 (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'];
|
|
} 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('id_category_thumb',$id_category_thumb);
|
|
return $this->display(__FILE__, 'left_img.tpl');
|
|
}
|
|
}
|