rinzlerx64 Posted April 1, 2014 Share Posted April 1, 2014 Hi, I've noticed that the block categories doesn't load at category pages showing subcategories and products. I've checked the html to be sure that it is hidden, but no. I've checked exceptions too and it should appear. Link to comment Share on other sites More sharing options...
benjamin utterback Posted April 1, 2014 Share Posted April 1, 2014 Hi, I've noticed that the block categories doesn't load at category pages showing subcategories and products. I've checked the html to be sure that it is hidden, but no. I've checked exceptions too and it should appear. Hi rinzlerx64, can you explain the issue more? I'm a bit confused as to how to reproduce it. Thanks for the message! I will do my best to help. 1 Link to comment Share on other sites More sharing options...
rinzlerx64 Posted April 2, 2014 Author Share Posted April 2, 2014 Hi Benjamin, Thanks for you answer! I have configured my category tree like this:. Home .Products .Category of products .Product The problem is that when category of products are diplayed the block category module hooked in left column disappears, and I mean that it isn't even loaded (in some case I've read it could be hidden by css). I've checked the hook in this page and it's ok, CMS block hooked there is loaded and displayed.I've also checked the module's exceptions and there is no exception that could be applied in this page.I'm kind of stuck there, thanks for your help! Link to comment Share on other sites More sharing options...
TinoCas Posted April 22, 2014 Share Posted April 22, 2014 Same here... all the HMTL code in the block is there but the <li> completing the menu list... so it is including de module on that hook, but it isnt filling the <ul> list with the subcategories... I tried stick it up on the header.tpl, but even though. It seems that once your are on the category page, it can´t find any other on the store.Terribly stuck here also, using PS 1.6.0.5 1 Link to comment Share on other sites More sharing options...
Sazuki Posted April 28, 2014 Share Posted April 28, 2014 Hi, any solution for this issue? Link to comment Share on other sites More sharing options...
vekia Posted April 28, 2014 Share Posted April 28, 2014 if subcategory page hasn't got any subcategories to display, block will not appear. this is how this module works in prestashop 1.6 Link to comment Share on other sites More sharing options...
TinoCas Posted April 28, 2014 Share Posted April 28, 2014 if subcategory page hasn't got any subcategories to display, block will not appear. this is how this module works in prestashop 1.6 Thanks Vekia, I understand that... but is there any way, or trick... to keep the list of Main Categories diplayed all the time? including when you are inside one the categories? I tried to replicate or trick the smarty code in many ways on the .tpl files... but no success. I wouldnt like to go nuts trying to find the function on the core, because even if I find it, I´m afraid that it wont work unles I chage a fare few of functions.. no only that use on the filling the <li>... Link to comment Share on other sites More sharing options...
vekia Posted April 28, 2014 Share Posted April 28, 2014 you can use code of module that is a part of block categories module from 1.5 version just copy code of hookDisplayLeftColumn and hookDisplayRightColumn functions. and replace this code in your blockcategories (use code from 1.5 in 1.6) Link to comment Share on other sites More sharing options...
rinzlerx64 Posted April 29, 2014 Author Share Posted April 29, 2014 Hi vekia,Could you please post the code? Thanks! Link to comment Share on other sites More sharing options...
vekia Posted April 29, 2014 Share Posted April 29, 2014 As you wish here it is: replace original code with: (only functions that i pasted below) public function getTree($resultParents, $resultIds, $maxDepth, $id_category = null, $currentDepth = 0) { if (is_null($id_category)) $id_category = $this->context->shop->getCategory(); $children = array(); if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $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; $return = array('id' => $id_category, 'link' => $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'], 'children' => $children); return $return; } public function hookLeftColumn($params) { if (!$this->isCached('blockcategories.tpl', $this->getCacheId())) { // Get all groups for this customer and concatenate them as a string: "1,2,3..." $groups = implode(', ', Customer::getGroupsStatic((int)$this->context->customer->id)); $maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH'); if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT DISTINCT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite FROM `'._DB_PREFIX_.'category` c INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').') INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)$this->context->shop->id.') WHERE (c.`active` = 1 OR c.`id_category` = '.(int)Configuration::get('PS_HOME_CATEGORY').') AND c.`id_category` != '.(int)Configuration::get('PS_ROOT_CATEGORY').' '.((int)$maxdepth != 0 ? ' AND `level_depth` <= '.(int)$maxdepth : '').' AND c.id_category IN (SELECT id_category FROM `'._DB_PREFIX_.'category_group` WHERE `id_group` IN ('.pSQL($groups).')) ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'cs.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) return; $resultParents = array(); $resultIds = array(); $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false); 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')); unset($resultParents, $resultIds); $this->smarty->assign('blockCategTree', $blockCategTree); if (file_exists(_PS_THEME_DIR_.'modules/blockcategories/blockcategories.tpl')) $this->smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategories/category-tree-branch.tpl'); else $this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl'); $this->smarty->assign('isDhtml', $isDhtml); } $id_category = (int)Tools::getValue('id_category'); $id_product = (int)Tools::getValue('id_product'); if (Tools::isSubmit('id_category')) { $this->context->cookie->last_visited_category = (int)$id_category; $this->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category); } if (Tools::isSubmit('id_product')) { if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))) || !Category::inShopStatic($this->context->cookie->last_visited_category, $this->context->shop)) { $product = new Product((int)$id_product); if (isset($product) && Validate::isLoadedObject($product)) $this->context->cookie->last_visited_category = (int)$product->id_category_default; } $this->smarty->assign('currentCategoryId', (int)$this->context->cookie->last_visited_category); } $display = $this->display(__FILE__, 'blockcategories.tpl', $this->getCacheId()); return $display; } protected function getCacheId($name = null) { parent::getCacheId($name); $groups = implode(', ', Customer::getGroupsStatic((int)$this->context->customer->id)); $id_product = (int)Tools::getValue('id_product', 0); $id_category = (int)Tools::getValue('id_category', 0); $id_lang = (int)$this->context->language->id; return 'blockcategories|'.(int)Tools::usingSecureMode().'|'.$this->context->shop->id.'|'.$groups.'|'.$id_lang.'|'.$id_product.'|'.$id_category; } public function hookFooter($params) { // Get all groups for this customer and concatenate them as a string: "1,2,3..." if (!$this->isCached('blockcategories_footer.tpl', $this->getCacheId())) { $maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH'); $groups = implode(', ', Customer::getGroupsStatic((int)$this->context->customer->id)); if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT DISTINCT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite FROM `'._DB_PREFIX_.'category` c '.Shop::addSqlAssociation('category', 'c').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->context->language->id.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).') ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'category_shop.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) return; $resultParents = array(); $resultIds = array(); foreach ($result as &$row) { $resultParents[$row['id_parent']][] = &$row; $resultIds[$row['id_category']] = &$row; } //$nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMNS_FOOTER'); $nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMN_FOOTER'); if (!$nbrColumns) $nbrColumns = 3; $numberColumn = abs(count($result) / $nbrColumns); $widthColumn = floor(100 / $nbrColumns); $this->smarty->assign('numberColumn', $numberColumn); $this->smarty->assign('widthColumn', $widthColumn); $blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH')); unset($resultParents, $resultIds); $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false); $id_category = (int)Tools::getValue('id_category'); $id_product = (int)Tools::getValue('id_product'); if (Tools::isSubmit('id_category')) { $this->context->cookie->last_visited_category = $id_category; $this->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category); } if (Tools::isSubmit('id_product')) { if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) { $product = new Product($id_product); if (isset($product) && Validate::isLoadedObject($product)) $this->context->cookie->last_visited_category = (int)($product->id_category_default); } $this->smarty->assign('currentCategoryId', (int)($this->context->cookie->last_visited_category)); } $this->smarty->assign('blockCategTree', $blockCategTree); if (file_exists(_PS_THEME_DIR_.'modules/blockcategories/blockcategories_footer.tpl')) $this->smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategories/category-tree-branch.tpl'); else $this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl'); $this->smarty->assign('isDhtml', $isDhtml); } $display = $this->display(__FILE__, 'blockcategories_footer.tpl', $this->getCacheId()); return $display; } public function hookRightColumn($params) { return $this->hookLeftColumn($params); } public function hookHeader() { $this->context->controller->addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); $this->context->controller->addCSS(($this->_path).'blockcategories.css', 'all'); } private function _clearBlockcategoriesCache() { $this->_clearCache('blockcategories.tpl'); $this->_clearCache('blockcategories_footer.tpl'); } public function hookCategoryAddition($params) { $this->_clearBlockcategoriesCache(); } public function hookCategoryUpdate($params) { $this->_clearBlockcategoriesCache(); } public function hookCategoryDeletion($params) { $this->_clearBlockcategoriesCache(); } public function hookActionAdminMetaControllerUpdate_optionsBefore($params) { $this->_clearBlockcategoriesCache(); } Link to comment Share on other sites More sharing options...
TinoCas Posted April 29, 2014 Share Posted April 29, 2014 Hi Vekia, I really appreciate your help... Unfortunately i didnt work for me. I´ve replaced those functions in the blockcategories.php inside my theme and it does nothing. Still coming out like this on the category page: <div id="categories_block_left" class="demo-container block"> <div class="tptn-vertical-mega-menu"> <ul id="mega-1" class="menu right"> </ul> </div> </div> Looks like the internal core doesnt find the categories on that level... it might need a much more serious surgery in PS1.6 brains!! Link to comment Share on other sites More sharing options...
robycrazy Posted May 11, 2014 Share Posted May 11, 2014 It works great But how to display in category block lable the name of current category, instead of the title "CATEGORY" ??? Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2014 Share Posted May 11, 2014 in module tpl ile use something like: {if $category->name}{$category->name}{else}{l s='Categories' mod='blockcategories'} Link to comment Share on other sites More sharing options...
robycrazy Posted May 11, 2014 Share Posted May 11, 2014 (edited) in blockcategories.tpl there is something like : <h2 class="title_block"> {if isset($currentCategory)} {$currentCategory->name|escape} {else} {l s='Categories' mod='blockcategories'} {/if} but it doesn't work like that... at first we modify php file and title stay permanent "category" although in which category we are, why must modify tpl file ?! Can you help!?! Respect Vekia! Edited May 11, 2014 by robycrazy (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2014 Share Posted May 11, 2014 code that i suggested to use will display currently viewed category name instead of "CATEGORY"this is not what you expect? perhaps i missed something ... Link to comment Share on other sites More sharing options...
robycrazy Posted May 13, 2014 Share Posted May 13, 2014 code that i suggested to use will display currently viewed category name instead of "CATEGORY"this is not what you expect? this is exactly what i want, but its not working like that... or i put the code at wrong place .. Link to comment Share on other sites More sharing options...
TinoCas Posted May 14, 2014 Share Posted May 14, 2014 Hi guys... Sorry but you are discussing a completely different thing that what we started here and we are still missing a solution for the original post.Please open a new topic for it if you still need to go on with that. In this one we were trying to fix another thing... and at the end it will get closed without a fix for the original problem. Thanx Still couldnt find a way to display the listy of categories on that page and clock is ticking. Could anybody come back to the topic and gimme some ideas? Vekia, I tried what you suggested and still not working... is there a way to wirte the SQL query or function, and bring the list on your own? Do I explain myself? Thanx Link to comment Share on other sites More sharing options...
robycrazy Posted May 14, 2014 Share Posted May 14, 2014 TinoCas - the topic is Categories block doesn't load at subcategory page, and the the solution for that is posted by VEKIA - #10. It works fine! And we discuss a problem connected with this showing of category block!!!! Link to comment Share on other sites More sharing options...
Tomas Benda Posted May 18, 2014 Share Posted May 18, 2014 Thank you Vekia. It working! :-) For those, where is not working. Just open file ./modules/blockcategories/blockcategories.php and change only functions, what Vekia sends. Or if you are not familiar with PHP, just unzip this file http://tomasbenda.cz/download/blockcategories.zip and exchange it for original file, which is in on your FTP here ./modules/blockcategories/blockcategories.php. It worked for Prestashop version 1.6.0.6. But before that backup your original blockcategories.php file, if will doesnt work for you. Link to comment Share on other sites More sharing options...
digites Posted May 29, 2014 Share Posted May 29, 2014 (edited) Thank you Vekia. It working! :-) For those, where is not working. Just open file ./modules/blockcategories/blockcategories.php and change only functions, what Vekia sends. Or if you are not familiar with PHP, just unzip this file http://tomasbenda.cz/download/blockcategories.zip and exchange it for original file, which is in on your FTP here ./modules/blockcategories/blockcategories.php. It worked for Prestashop version 1.6.0.6. But before that backup your original blockcategories.php file, if will doesnt work for you. I replace original blockcategories.php file - and it works very well, but for one day... Today i open my website and situation is the same - category block is only showed on category tab... Prestashop 1.6.0.6 Edited May 29, 2014 by digites (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 29, 2014 Share Posted May 29, 2014 perhaps you upgraded modules? also block categories? Link to comment Share on other sites More sharing options...
digites Posted May 31, 2014 Share Posted May 31, 2014 I didn't upgrade this module. Is it possible to PrestaShop automaticly upgraded this module without my integration? If yes, how can I turn off automaticly updates? Link to comment Share on other sites More sharing options...
digites Posted June 9, 2014 Share Posted June 9, 2014 I noticed that the problem disappears when I turn off cache Link to comment Share on other sites More sharing options...
kiran4prestashop Posted June 27, 2014 Share Posted June 27, 2014 (edited) Hi Friends, Even i am also having the same issue, actually category block is displaying in all pages except list of products page. If i open any category then products are displaying related to the category which i clicked but left side categories are not displaying. Even I am having the issue when I opened any subcategory page. Thanks Inadvance... Edited June 27, 2014 by kiran4prestashop (see edit history) Link to comment Share on other sites More sharing options...
alinstan Posted July 29, 2014 Share Posted July 29, 2014 Another fix that worked for me: 1. go to modules 2. search categories block 3. edit 4. change "category root" option to "home category" instead of "current category" 2 Link to comment Share on other sites More sharing options...
namelesshachi Posted August 8, 2014 Share Posted August 8, 2014 (edited) Another fix that worked for me: 1. go to modules 2. search categories block 3. edit 4. change "category root" option to "home category" instead of "current category" Alinstan solution works amazing! and no touching on any code! Thanks! Edited August 8, 2014 by namelesshachi (see edit history) Link to comment Share on other sites More sharing options...
zeki893 Posted September 10, 2014 Share Posted September 10, 2014 I'm on 1.6.0.9 w/ blockcategories 2.8.2 and still have this problem. I downloaded v1.5 blockcategories.php that was posted and that doesn't work either. I tried changing category root option to 'home category' as mentioned in above post then the category menu doesn't even display on the left column of a regular category page either. Any resolutions here? Link to comment Share on other sites More sharing options...
vekia Posted September 10, 2014 Share Posted September 10, 2014 let's clarify what else you did: 1) have you checked exceptions? go to modules> modules and check if module has got exceptions related to appearaing in displayLeftColumn 2) have you tried to remove module files (if not - backup them first!) from /themes/your-theme/modules/blockcategories/ Link to comment Share on other sites More sharing options...
dayfus Posted October 23, 2014 Share Posted October 23, 2014 Thks, Vekia. Great solution. Works 100% Link to comment Share on other sites More sharing options...
Recommended Posts