bebeboutik/modules/categoryimg/categoryimg.php

60 lines
1.9 KiB
PHP
Raw Normal View History

2016-01-04 12:49:26 +01:00
<?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;
2016-08-30 13:55:47 +02:00
2016-01-04 12:49:26 +01:00
$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 = "";
}
}
}
2016-08-31 12:41:07 +02:00
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;
}
2016-01-04 12:49:26 +01:00
$sale = Sale::getSaleFromCategory(Tools::getValue('id_category'));
$smarty->assign('sale', $sale);
2016-04-18 16:03:17 +02:00
$smarty->assign('consumable', ((int) _SHOP_PRIVATESALES_CONSUMABLE == (int) $sale->id)? true : false);
2016-01-04 12:49:26 +01:00
$smarty->assign('category', $category);
2016-08-31 12:41:07 +02:00
$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);
2016-01-04 12:49:26 +01:00
return $this->display(__FILE__, 'left_img.tpl');
}
}