Jump to content

[Module] block Categories with Image V3.0 - Ps1.2/1.7


Recommended Posts

Show categories with thumbnails

categories-image-prestashop-module.jpg

no need to regenerate!

 

(now with subcategories image and size)

 

added compatibility with url rewriting

 

i update the version to 1.7 and works like the block categories, and now reduce the image in subcategories

Updated with Link function for images and solves ssl errors

 

v3.0-blockcategoriesi.zip

 

categoriesimage.jpg

Share this post


Link to post
Share on other sites

Thanks shacker for sharing this free module ;)
Probably it is as great as all your other stuff you made, hope that it also works on the module Rocky blockcategoriesnc v2.0.

Will try it out and see what happens.

Thanks.

Best regards,


ysco..

Share this post


Link to post
Share on other sites
Thanks shacker for sharing this free module ;)
Probably it is as great as all your other stuff you made, hope that it also works on the module Rocky blockcategoriesnc v2.0.

Will try it out and see what happens.

Thanks.

Best regards,


ysco..


Hi Ysco. Maybe this modification works with any categories module. We add more and more modules this week. And i answer you questions today.

Best regards

Share this post


Link to post
Share on other sites

Hello shacker ;)

I was just looking at this module but i think that it won`t work easily with the module from Rocky 2.0 cause the files has different names so then i probably must manually add the modifications from yours into the one from rocky and then i don`t know if it works anyway.

How you guys do it bringing such many modules in short time ( and all are special ) not just simple ones it is just amazing how you do it ;)

Well i wait for your reply later this day buddy.

Best regards,

ysco..

Share this post


Link to post
Share on other sites
Hello shacker ;)

I was just looking at this module but i think that it won`t work easily with the module from Rocky 2.0 cause the files has different names so then i probably must manually add the modifications from yours into the one from rocky and then i don`t know if it works anyway.

How you guys do it bringing such many modules in short time ( and all are special ) not just simple ones it is just amazing how you do it ;)

Well i wait for your reply later this day buddy.

Best regards,

ysco..


Thanks Ysco. We read all your suggestions to develop future modules, and change the actual modules. you are a important customer for us, and your opinion is very useful.

best regards.

Share this post


Link to post
Share on other sites

I was planning to add an option to add category images to the next version of my module. I'll have to have a look at how you did it. It would be better if you added the download as an attachment, so it can be downloaded without registering first, though I understand if you are using this as a method to track who is downloading your modules.

Share this post


Link to post
Share on other sites

I suggest to give another name than blockcategories on archive because there are now several blockcategories customed modules with same name.
Why not blockcategoriesimage or blockcategoriesimg? it is very easy to do and more usefull ! ;-)

Share this post


Link to post
Share on other sites
I suggest to give another name than blockcategories on archive because there are now several blockcategories customed modules with same name.
Why not blockcategoriesimage or blockcategoriesimg? it is very easy to do and more usefull ! ;-)


Hi jolvil.
The problem is that this is the same block categories, only with image. The idea is replace the original module, no add another one.

Share this post


Link to post
Share on other sites

yes I know but the idea is not to confuse when you manage them. If you rename it, you can test it in BO easily, activating ans desactivatiing. I your case you have to overwrite the original module to test it.

Having his own name could be better I think

Share this post


Link to post
Share on other sites
I was planning to add an option to add category images to the next version of my module. I'll have to have a look at how you did it. It would be better if you added the download as an attachment, so it can be downloaded without registering first, though I understand if you are using this as a method to track who is downloading your modules.


Hi. we add in our site to track the downloads and the the users can view the other modules and themes.

Share this post


Link to post
Share on other sites
yes I know but the idea is not to confuse when you manage them. If you rename it, you can test it in BO easily, activating ans desactivatiing. I your case you have to overwrite the original module to test it.

Having his own name could be better I think


I understand your point and update very soon.
thanks

Share this post


Link to post
Share on other sites
yes I know but the idea is not to confuse when you manage them. If you rename it, you can test it in BO easily, activating ans desactivatiing. I your case you have to overwrite the original module to test it.

Having his own name could be better I think


I understand your point and update very soon.
thanks


Gracias!

Share this post


Link to post
Share on other sites
yes I know but the idea is not to confuse when you manage them. If you rename it, you can test it in BO easily, activating ans desactivatiing. I your case you have to overwrite the original module to test it.

Having his own name could be better I think


I understand your point and update very soon.
thanks


Gracias!


UPDATED. CHANGE THE NAME OF THE MODULE

Share this post


Link to post
Share on other sites
  • 4 months later...
  • 6 months later...
  • 4 weeks later...
The Module does not work sometimes

it does not load up the category pictures for some product pages please see the link below, the categories on the left do not show the images.

http://www.turkishfootballstore.com/besiktas-store-shop-bjk-kartal-yuvasi/261-besiktas-blanket-.html


This is becouse the url rewriting.we need to use absolute path

Share this post


Link to post
Share on other sites
  • 1 month later...
  • 4 weeks later...

When a category is selected with the module blockcategories, the block remains open on the active category.
But with the module blockcategoriesi, the active category is closed.
How to have the same effect on active category with the module blockcategoriesi ?

Share this post


Link to post
Share on other sites

i think is a problem with this version. maybe check the block categories and compare with the block categoriesi to check if some line is changed (not the current img added to the code)

Share this post


Link to post
Share on other sites
  • 1 month later...

i think the module is not compatible with v1.4.1

it displays the images ok, but javascript does not work. it's always in non dynamic mode.

i tried many things, i checked the code, but no luck...

Share this post


Link to post
Share on other sites
  • 3 weeks later...

i just tested a fresh install. the module works ok when the original categories module is enabled.
when i disable the original module, your module does not work in dynamic mode! the option in configuration does noy work.

also, the bold letters for category/subcategory are in reverse when you look the original catogories module.

i hope you see this and agree with me, because i really like this module and i would like to use it.

Share this post


Link to post
Share on other sites
  • 1 month later...

i noticed that the module shows the images from http: when the page is shown in https:

it's a small glitch that shows a warning window from the browser

Share this post


Link to post
Share on other sites
  • 3 weeks later...
  • 4 months later...

Hola shacker, gracias por el módulo blockcategoriesi

 

Lo he probado y aparentemente funciona muy bien visualmente, añadiendo fotografías a la izquierda de cada categoría, pero al tenerlo activado resulta que hay un problema a la hora de usar atributos sobre un producto con variaciones en su precio.

 

Me explico:

 

Si usamos por ejemplo, el grupo de atributos de colores y para por ej, el color azul mantenemos el precio normal del producto, pero para el color rojo le asignamos un incremento de "X" euros, a la hora de probarlo no funciona la variación de precio del atributo, a menos qué, se esté logueado en la tienda.

 

Si no estas logueado, no cambia el precio. En cambio con el módulo de Categorías sin imágenes por defecto de Prestashop, el precio si varía estés o no logueado en la tienda.

 

¿Sabrías algo acerca de este problema? :huh:

 

 

Muchas gracias por adelantado

Un saludo

Share this post


Link to post
Share on other sites
  • 2 weeks later...
  • 8 months later...

Hello,

I installed your module on my Prestashop 1.5 and got the following debug error after the site wouldn't load. I disabled the default category module as well...

 

Fatal error: Call to undefined method Shop::getID() in /home6/smallpet/public_html/ps150/modules/blockcategoriesi/blockcategoriesi.php on line 282

 

How do I solve this?

 

Thanks!

-Dave

  • Like 1

Share this post


Link to post
Share on other sites

<?php

 

class BlockCategoriesi extends Module

{

function __construct()

{

$this->name = 'blockcategoriesi';

if(_PS_VERSION_ > "1.4.0.0"){

$this->tab = 'front_office_features';

$this->author = 'RSI';

$this->need_instance = 0;

}else{

$this->tab = 'Blocks';

}

$this->version = 1.7;

 

parent::__construct();

 

$this->displayName = $this->l('Categories block image');

$this->description = $this->l('Adds a block featuring product categories - www.catalogo-onlienrsi.com.ar');

}

 

function install()

{

if(_PS_VERSION_ < "1.4.0.0"){

if (parent::install() == false

OR $this->registerHook('leftColumn') == false

OR Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', 3) == false

OR Configuration::updateValue('BLOCK_CATEGI_DHTML', 1) == false

OR Configuration::updateValue('BLOCK_CATEGI_IMAGE', 40) == false)

return false;

 

return true;

 

}

else{

if (!parent::install() OR

!$this->registerHook('leftColumn') OR

!$this->registerHook('header') OR

// Temporary hooks. Do NOT hook any module on it. Some CRUD hook will replace them as soon as possible.

!$this->registerHook('categoryAddition') OR

!$this->registerHook('categoryUpdate') OR

!$this->registerHook('categoryDeletion') OR

!Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', 3) OR

!Configuration::updateValue('BLOCK_CATEGI_DHTML', 1)OR

!Configuration::updateValue('BLOCK_CATEGI_IMAGE', 40))

return false;

return true;

}

}

 

public function getContent()

{

$output = '<h2>'.$this->displayName.'</h2>';

if (Tools::isSubmit('submitBlockCategoriesi'))

{

$maxDepth = intval(Tools::getValue('maxDepth'));

$dhtml = Tools::getValue('dhtml');

$image = Tools::getValue('image');

if ($maxDepth < 0)

$output .= '<div class="alert error">'.$this->l('Maximum depth: Invalid number.').'</div>';

elseif ($dhtml != 0 AND $dhtml != 1)

$output .= '<div class="alert error">'.$this->l('Dynamic HTML: Invalid choice.').'</div>';

else

{

Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', intval($maxDepth));

Configuration::updateValue('BLOCK_CATEGI_DHTML', intval($dhtml));

Configuration::updateValue('BLOCK_CATEGI_IMAGE', $image);

$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';

}

}

return $output.$this->displayForm();

}

 

public function displayForm()

{

return '

<form action="'.$_SERVER['REQUEST_URI'].'" method="post">

<fieldset>

<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>

<label>'.$this->l('Maximum depth').'</label>

<div class="margin-form">

<input type="text" name="maxDepth" value="'.Configuration::get('BLOCK_CATEGI_MAX_DEPTH').'" />

<p class="clear">'.$this->l('Set the maximum depth of sublevels displayed in this block (0 = infinite)').'</p>

</div>

 

<label>'.$this->l('Image size').'</label>

<div class="margin-form">

<input type="text" name="image" value="'.Configuration::get('BLOCK_CATEGI_IMAGE').'" />

 

</div>

<label>'.$this->l('Dynamic').'</label>

 

<div class="margin-form">

<input type="radio" name="dhtml" id="dhtml_on" value="1" '.(Tools::getValue('dhtml', Configuration::get('BLOCK_CATEGI_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>

<input type="radio" name="dhtml" id="dhtml_off" value="0" '.(!Tools::getValue('dhtml', Configuration::get('BLOCK_CATEGI_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>

<p class="clear">'.$this->l('Activate dynamic (animated) mode for sublevels').'</p>

</div>

<center><input type="submit" name="submitBlockCategoriesi" value="'.$this->l('Save').'" class="button" /></center>

</fieldset>

</form>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Contribute').'</legend>

<p class="clear">'.$this->l('You can contribute with a donation if our free modules and themes are usefull for you. Clic on the link and support us!').'</p>

<p class="clear">'.$this->l('For more modules & themes visit: www.catalogo-onlinersi.com.ar').'</p>

<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="HMBZNQAHN9UMJ">

<input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

<img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/scr/pixel.gif" width="1" height="1">

</fieldset>

</form>';

}

 

public function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0)

{

global $link;

 

$children = array();

if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth))

foreach ($resultParents[$id_category] as $subcat)

$children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1);

if (!isset($resultIds[$id_category]))

return false;

if ( _PS_VERSION_ < "1.4.0.0"){

return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),

'name' => Category::hideCategoryPosition($resultIds[$id_category]['name']), 'desc'=> $resultIds[$id_category]['description'],

'children' => $children);

}

else{

return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),

'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'],

'children' => $children);

}

}

 

function hookLeftColumn($params)

{

global $smarty, $cookie, $category;

$psversion = _PS_VERSION_;

if (_PS_VERSION_ < "1.4.0.0"){

/* ONLY FOR THEME OLDER THAN v1.0 */

global $link;

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$smarty->assign(array(

'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),

'image' => $image,

'link' => $link

));

/* ELSE */

$id_customer = intval($params['cookie']->id_customer);

$maxdepth = Configuration::get('BLOCK_CATEGI_MAX_DEPTH');

 

if (!$result = Db::getInstance()->ExecuteS('

SELECT DISTINCT c.*, cl.*

FROM `'._DB_PREFIX_.'category` c

LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.intval($params['cookie']->id_lang).')

LEFT JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = c.`id_category`)

'.($id_customer ? 'INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = '.intval($id_customer).')' : '' ).'

WHERE 1'

.(intval($maxdepth) != 0 ? ' AND `level_depth` <= '.intval($maxdepth) : '').'

AND (c.`active` = 1 OR c.`id_category`= 1)

'.(!$id_customer ? 'AND ctg.`id_group` = 1' : '' ).'

ORDER BY `level_depth` ASC, cl.`name` ASC'))

return;

$resultParents = array();

$resultIds = array();

 

foreach ($result as $row)

{

$$row['name'] = Category::hideCategoryPosition($row['name']);

$resultParents[$row['id_parent']][] = $row;

$resultIds[$row['id_category']] = $row;

}

$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEGI_MAX_DEPTH'));

$isDhtml = (Configuration::get('BLOCK_CATEGI_DHTML') == 1 ? true : false);

 

if (isset($_GET['id_category']))

{

$cookie->last_visited_category = intval($_GET['id_category']);

$smarty->assign('currentCategoryId', intval($_GET['id_category']));

}

if (isset($_GET['id_product']))

{

if (!isset($cookie->last_visited_category) OR !Product::idIsOnCategoryId(intval($_GET['id_product']), array('0' => array('id_category' => $cookie->last_visited_category))))

{

$product = new Product(intval($_GET['id_product']));

if (isset($product) AND Validate::isLoadedObject($product))

$cookie->last_visited_category = intval($product->id_category_default);

}

$smarty->assign('currentCategoryId', intval($cookie->last_visited_category));

}

$smarty->assign('blockCategTree', $blockCategTree);

 

if (file_exists(_PS_THEME_DIR_.'modules/blockcategoriesi/blockcategoriesi.tpl'))

$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategoriesi/category-tree-branch.tpl');

else

$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$smarty->assign('isDhtml', $isDhtml);

/* /ONLY FOR THEME OLDER THAN v1.0 */

$smarty->assign('psversion', $psversion);

return $this->display(__FILE__, 'blockcategoriesi.tpl');

}

if(_PS_VERSION_ < "1.5.0.0" && _PS_VERSION_ > "1.4.0.0")

{

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$images = $image - 10;

$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 = 'blockcategoriesi|'.$id_group.'_'.$id_lang.'_'.$id_product.'_'.$id_category;

 

Tools::enableCache();

if (!$this->isCached('blockcategoriesi.tpl', $smartyCacheId))

{

$maxdepth = Configuration::get('BLOCK_CATEGI_MAX_DEPTH');

 

if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('

SELECT DISTINCT c.*, cl.*

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 1'

.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'

AND (c.`active` = 1 OR c.`id_category` = 1)

AND cg.`id_group` = '.$id_group.'

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_CATEGI_MAX_DEPTH'));

unset($resultParents);

unset($resultIds);

$isDhtml = (Configuration::get('BLOCK_CATEGI_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/blockcategoriesi/blockcategoriesi.tpl'))

$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategoriesi/category-tree-branch.tpl');

else

$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$smarty->assign('isDhtml', $isDhtml);

}

$smarty->assign('image', $image);

$smarty->assign('images', $images);

$smarty->assign('psversion', $psversion);

$smarty->cache_lifetime = 31536000; // 1 Year

 

 

$display = $this->display(__FILE__, 'blockcategoriesi.tpl', $smartyCacheId);

Tools::restoreCacheSettings();

return $display;

}

else{

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$images = $image - 10;

$id_current_shop = $this->context->shop->getID();

 

$id_customer = (int)($params['cookie']->id_customer);

// Get all groups for this customer and concatenate them as a string: "1,2,3..."

// It is necessary to keep the group query separate from the main select query because it is used for the cache

$groups = $id_customer ? implode(', ', Customer::getGroupsStatic($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 = 'blockcategories|'.$id_current_shop.'_'.$groups.'_'.$id_lang.'_'.$id_product.'_'.$id_category;

 

/*Tools::enableCache();

if (!$this->isCached('blockcategories.tpl', $smartyCacheId))

{*/

$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');

/*p('

SELECT c.id_parent, c.id_category, 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 cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')

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` IN ('.pSQL($groups).')

GROUP BY id_category

ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));*/

if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('

SELECT c.id_parent, c.id_category, 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 cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')

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` IN ('.pSQL($groups).')

GROUP BY id_category

ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))

)

 

return Tools::restoreCacheSettings();

 

$resultParents = array();

$resultIds = array();

 

foreach ($result as &$row)

{

$resultParents[$row['id_parent']][] = &$row;

$resultIds[$row['id_category']] = &$row;

}

//p($resultParents);

$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'));

unset($resultParents, $resultIds);

//d($blockCategTree);

$isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

if (Tools::isSubmit('id_category'))

{

$this->context->cookie->last_visited_category = $id_category;

$this->context->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category);

}

if (Tools::isSubmit('id_product'))

{

if (!isset($this->context->cookie->last_visited_category) OR !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))))

{

$product = new Product($id_product);

if (isset($product) AND Validate::isLoadedObject($product))

$this->context->cookie->last_visited_category = (int)($product->id_category_default);

}

$this->context->smarty->assign('currentCategoryId', (int)($this->context->cookie->last_visited_category));

}

$this->context->smarty->assign('blockCategTree', $blockCategTree);

 

if (file_exists(_PS_THEME_DIR_.'modules/blockcategoriesi/blockcategoriesi.tpl'))

$this->context->smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategorieis/category-tree-branch.tpl');

else

$this->context->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$this->context->smarty->assign('isDhtml', $isDhtml);

//}

$smarty->assign('image', $image);

$smarty->assign('images', $images);

$smarty->assign('psversion', $psversion);

$this->context->smarty->cache_lifetime = 31536000; // 1 Year

$display = $this->display(__FILE__, 'blockcategoriesi.tpl', $smartyCacheId);

Tools::restoreCacheSettings();

return $display;

}

}

 

public function hookRightColumn($params)

{

return $this->hookLeftColumn($params);

}

 

public function hookHeader()

{

if(_PS_VERSION_ > "1.4.0.0"){

Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js');

Tools::addCSS(($this->_path).'blockcategories.css', 'all');

}

}

 

private function _clearBlockcategoriesCache()

{

$this->_clearCache(NULL, 'blockcategories');

Tools::restoreCacheSettings();

}

 

public function hookCategoryAddition($params)

{

$this->_clearBlockcategoriesCache();

}

 

public function hookCategoryUpdate($params)

{

$this->_clearBlockcategoriesCache();

}

 

public function hookCategoryDeletion($params)

{

$this->_clearBlockcategoriesCache();

}

}

 

?>

 

^Copy and Paste of the blockcategoriesi.php

Share this post


Link to post
Share on other sites

<?php

 

class BlockCategoriesi extends Module

{

function __construct()

{

$this->name = 'blockcategoriesi';

if(_PS_VERSION_ > "1.4.0.0"){

$this->tab = 'front_office_features';

$this->author = 'RSI';

$this->need_instance = 0;

}else{

$this->tab = 'Blocks';

}

$this->version = 1.7;

 

parent::__construct();

 

$this->displayName = $this->l('Categories block image');

$this->description = $this->l('Adds a block featuring product categories - www.catalogo-onlienrsi.com.ar');

}

 

function install()

{

if(_PS_VERSION_ < "1.4.0.0"){

if (parent::install() == false

OR $this->registerHook('leftColumn') == false

OR Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', 3) == false

OR Configuration::updateValue('BLOCK_CATEGI_DHTML', 1) == false

OR Configuration::updateValue('BLOCK_CATEGI_IMAGE', 40) == false)

return false;

 

return true;

 

}

else{

if (!parent::install() OR

!$this->registerHook('leftColumn') OR

!$this->registerHook('header') OR

// Temporary hooks. Do NOT hook any module on it. Some CRUD hook will replace them as soon as possible.

!$this->registerHook('categoryAddition') OR

!$this->registerHook('categoryUpdate') OR

!$this->registerHook('categoryDeletion') OR

!Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', 3) OR

!Configuration::updateValue('BLOCK_CATEGI_DHTML', 1)OR

!Configuration::updateValue('BLOCK_CATEGI_IMAGE', 40))

return false;

return true;

}

}

 

public function getContent()

{

$output = '<h2>'.$this->displayName.'</h2>';

if (Tools::isSubmit('submitBlockCategoriesi'))

{

$maxDepth = intval(Tools::getValue('maxDepth'));

$dhtml = Tools::getValue('dhtml');

$image = Tools::getValue('image');

if ($maxDepth < 0)

$output .= '<div class="alert error">'.$this->l('Maximum depth: Invalid number.').'</div>';

elseif ($dhtml != 0 AND $dhtml != 1)

$output .= '<div class="alert error">'.$this->l('Dynamic HTML: Invalid choice.').'</div>';

else

{

Configuration::updateValue('BLOCK_CATEGI_MAX_DEPTH', intval($maxDepth));

Configuration::updateValue('BLOCK_CATEGI_DHTML', intval($dhtml));

Configuration::updateValue('BLOCK_CATEGI_IMAGE', $image);

$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';

}

}

return $output.$this->displayForm();

}

 

public function displayForm()

{

return '

<form action="'.$_SERVER['REQUEST_URI'].'" method="post">

<fieldset>

<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>

<label>'.$this->l('Maximum depth').'</label>

<div class="margin-form">

<input type="text" name="maxDepth" value="'.Configuration::get('BLOCK_CATEGI_MAX_DEPTH').'" />

<p class="clear">'.$this->l('Set the maximum depth of sublevels displayed in this block (0 = infinite)').'</p>

</div>

 

<label>'.$this->l('Image size').'</label>

<div class="margin-form">

<input type="text" name="image" value="'.Configuration::get('BLOCK_CATEGI_IMAGE').'" />

 

</div>

<label>'.$this->l('Dynamic').'</label>

 

<div class="margin-form">

<input type="radio" name="dhtml" id="dhtml_on" value="1" '.(Tools::getValue('dhtml', Configuration::get('BLOCK_CATEGI_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>

<input type="radio" name="dhtml" id="dhtml_off" value="0" '.(!Tools::getValue('dhtml', Configuration::get('BLOCK_CATEGI_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>

<p class="clear">'.$this->l('Activate dynamic (animated) mode for sublevels').'</p>

</div>

<center><input type="submit" name="submitBlockCategoriesi" value="'.$this->l('Save').'" class="button" /></center>

</fieldset>

</form>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Contribute').'</legend>

<p class="clear">'.$this->l('You can contribute with a donation if our free modules and themes are usefull for you. Clic on the link and support us!').'</p>

<p class="clear">'.$this->l('For more modules & themes visit: www.catalogo-onlinersi.com.ar').'</p>

<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="HMBZNQAHN9UMJ">

<input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

<img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/scr/pixel.gif" width="1" height="1">

</fieldset>

</form>';

}

 

public function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0)

{

global $link;

 

$children = array();

if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth))

foreach ($resultParents[$id_category] as $subcat)

$children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1);

if (!isset($resultIds[$id_category]))

return false;

if ( _PS_VERSION_ < "1.4.0.0"){

return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),

'name' => Category::hideCategoryPosition($resultIds[$id_category]['name']), 'desc'=> $resultIds[$id_category]['description'],

'children' => $children);

}

else{

return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),

'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'],

'children' => $children);

}

}

 

function hookLeftColumn($params)

{

global $smarty, $cookie, $category;

$psversion = _PS_VERSION_;

if (_PS_VERSION_ < "1.4.0.0"){

/* ONLY FOR THEME OLDER THAN v1.0 */

global $link;

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$smarty->assign(array(

'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),

'image' => $image,

'link' => $link

));

/* ELSE */

$id_customer = intval($params['cookie']->id_customer);

$maxdepth = Configuration::get('BLOCK_CATEGI_MAX_DEPTH');

 

if (!$result = Db::getInstance()->ExecuteS('

SELECT DISTINCT c.*, cl.*

FROM `'._DB_PREFIX_.'category` c

LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.intval($params['cookie']->id_lang).')

LEFT JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = c.`id_category`)

'.($id_customer ? 'INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = '.intval($id_customer).')' : '' ).'

WHERE 1'

.(intval($maxdepth) != 0 ? ' AND `level_depth` <= '.intval($maxdepth) : '').'

AND (c.`active` = 1 OR c.`id_category`= 1)

'.(!$id_customer ? 'AND ctg.`id_group` = 1' : '' ).'

ORDER BY `level_depth` ASC, cl.`name` ASC'))

return;

$resultParents = array();

$resultIds = array();

 

foreach ($result as $row)

{

$$row['name'] = Category::hideCategoryPosition($row['name']);

$resultParents[$row['id_parent']][] = $row;

$resultIds[$row['id_category']] = $row;

}

$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEGI_MAX_DEPTH'));

$isDhtml = (Configuration::get('BLOCK_CATEGI_DHTML') == 1 ? true : false);

 

if (isset($_GET['id_category']))

{

$cookie->last_visited_category = intval($_GET['id_category']);

$smarty->assign('currentCategoryId', intval($_GET['id_category']));

}

if (isset($_GET['id_product']))

{

if (!isset($cookie->last_visited_category) OR !Product::idIsOnCategoryId(intval($_GET['id_product']), array('0' => array('id_category' => $cookie->last_visited_category))))

{

$product = new Product(intval($_GET['id_product']));

if (isset($product) AND Validate::isLoadedObject($product))

$cookie->last_visited_category = intval($product->id_category_default);

}

$smarty->assign('currentCategoryId', intval($cookie->last_visited_category));

}

$smarty->assign('blockCategTree', $blockCategTree);

 

if (file_exists(_PS_THEME_DIR_.'modules/blockcategoriesi/blockcategoriesi.tpl'))

$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategoriesi/category-tree-branch.tpl');

else

$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$smarty->assign('isDhtml', $isDhtml);

/* /ONLY FOR THEME OLDER THAN v1.0 */

$smarty->assign('psversion', $psversion);

return $this->display(__FILE__, 'blockcategoriesi.tpl');

}

if(_PS_VERSION_ < "1.5.0.0" && _PS_VERSION_ > "1.4.0.0")

{

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$images = $image - 10;

$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 = 'blockcategoriesi|'.$id_group.'_'.$id_lang.'_'.$id_product.'_'.$id_category;

 

Tools::enableCache();

if (!$this->isCached('blockcategoriesi.tpl', $smartyCacheId))

{

$maxdepth = Configuration::get('BLOCK_CATEGI_MAX_DEPTH');

 

if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('

SELECT DISTINCT c.*, cl.*

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 1'

.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'

AND (c.`active` = 1 OR c.`id_category` = 1)

AND cg.`id_group` = '.$id_group.'

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_CATEGI_MAX_DEPTH'));

unset($resultParents);

unset($resultIds);

$isDhtml = (Configuration::get('BLOCK_CATEGI_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/blockcategoriesi/blockcategoriesi.tpl'))

$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategoriesi/category-tree-branch.tpl');

else

$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$smarty->assign('isDhtml', $isDhtml);

}

$smarty->assign('image', $image);

$smarty->assign('images', $images);

$smarty->assign('psversion', $psversion);

$smarty->cache_lifetime = 31536000; // 1 Year

 

 

$display = $this->display(__FILE__, 'blockcategoriesi.tpl', $smartyCacheId);

Tools::restoreCacheSettings();

return $display;

}

else{

$image = Configuration::get('BLOCK_CATEGI_IMAGE');

$images = $image - 10;

$id_current_shop = $this->context->shop->getID();

 

$id_customer = (int)($params['cookie']->id_customer);

// Get all groups for this customer and concatenate them as a string: "1,2,3..."

// It is necessary to keep the group query separate from the main select query because it is used for the cache

$groups = $id_customer ? implode(', ', Customer::getGroupsStatic($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 = 'blockcategories|'.$id_current_shop.'_'.$groups.'_'.$id_lang.'_'.$id_product.'_'.$id_category;

 

/*Tools::enableCache();

if (!$this->isCached('blockcategories.tpl', $smartyCacheId))

{*/

$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');

/*p('

SELECT c.id_parent, c.id_category, 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 cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')

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` IN ('.pSQL($groups).')

GROUP BY id_category

ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));*/

if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('

SELECT c.id_parent, c.id_category, 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 cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')

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` IN ('.pSQL($groups).')

GROUP BY id_category

ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))

)

 

return Tools::restoreCacheSettings();

 

$resultParents = array();

$resultIds = array();

 

foreach ($result as &$row)

{

$resultParents[$row['id_parent']][] = &$row;

$resultIds[$row['id_category']] = &$row;

}

//p($resultParents);

$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'));

unset($resultParents, $resultIds);

//d($blockCategTree);

$isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

if (Tools::isSubmit('id_category'))

{

$this->context->cookie->last_visited_category = $id_category;

$this->context->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category);

}

if (Tools::isSubmit('id_product'))

{

if (!isset($this->context->cookie->last_visited_category) OR !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))))

{

$product = new Product($id_product);

if (isset($product) AND Validate::isLoadedObject($product))

$this->context->cookie->last_visited_category = (int)($product->id_category_default);

}

$this->context->smarty->assign('currentCategoryId', (int)($this->context->cookie->last_visited_category));

}

$this->context->smarty->assign('blockCategTree', $blockCategTree);

 

if (file_exists(_PS_THEME_DIR_.'modules/blockcategoriesi/blockcategoriesi.tpl'))

$this->context->smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategorieis/category-tree-branch.tpl');

else

$this->context->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategoriesi/category-tree-branch.tpl');

$this->context->smarty->assign('isDhtml', $isDhtml);

//}

$smarty->assign('image', $image);

$smarty->assign('images', $images);

$smarty->assign('psversion', $psversion);

$this->context->smarty->cache_lifetime = 31536000; // 1 Year

$display = $this->display(__FILE__, 'blockcategoriesi.tpl', $smartyCacheId);

Tools::restoreCacheSettings();

return $display;

}

}

 

public function hookRightColumn($params)

{

return $this->hookLeftColumn($params);

}

 

public function hookHeader()

{

if(_PS_VERSION_ > "1.4.0.0"){

Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js');

Tools::addCSS(($this->_path).'blockcategories.css', 'all');

}

}

 

private function _clearBlockcategoriesCache()

{

$this->_clearCache(NULL, 'blockcategories');

Tools::restoreCacheSettings();

}

 

public function hookCategoryAddition($params)

{

$this->_clearBlockcategoriesCache();

}

 

public function hookCategoryUpdate($params)

{

$this->_clearBlockcategoriesCache();

}

 

public function hookCategoryDeletion($params)

{

$this->_clearBlockcategoriesCache();

}

}

 

?>

 

^Copy and Paste of the blockcategoriesi.php

 

Have you find any solution?

Share this post


Link to post
Share on other sites
  • 2 weeks later...
  • 4 months later...

Hola!!

Cuando lo instalo me da error 500 ¿Sabes por que puede ser? Te lo dejo instalado en mi segunda tienda www.kebonitas.es/licencias

Saludos

descargalo de nuevo de nuestro sitio. lo hemos actualizado

Share this post


Link to post
Share on other sites
  • 2 months later...

I thought I had to go where indicated in the picture

 

 

 

i'm sorry, I did not realize that was down the module, is very well, thank you very much and sorry for the inconvenience

post-528547-0-93403200-1368023557_thumb.jpg

Edited by fruns (see edit history)

Share this post


Link to post
Share on other sites

good again. I have questions or problems,

1st - I do not like has been displaced the name of the category for the image (photo 1), I would like to remain as the photo 2, ie, after the image name.

2 - I've noticed that when I click a category automatically becomes empty the category, this is normal? (photo 3)

post-528547-0-98315700-1368037617_thumb.jpg

post-528547-0-31041300-1368037624_thumb.jpg

post-528547-0-22444300-1368037626_thumb.jpg

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Hi,

 

Versions presta: 1.4.9.0

Version Categories image: 2.1

 

 

Image not appear after activating Friendly URLs but when is disable image appear.

Is possible to work when activating Friendly URLs ?

 

Thx.

Share this post


Link to post
Share on other sites
  • 3 weeks later...

v2.2-bugfix friendly url ps 1.4

 

Hi,

 

Versions presta: 1.4.9.0

Version Categories image: 2.1

 

 

Image not appear after activating Friendly URLs but when is disable image appear.

Is possible to work when activating Friendly URLs ?

 

Thx.

redownload latest version

Share this post


Link to post
Share on other sites
  • 3 months later...
  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More