herchri Posted December 25, 2011 Share Posted December 25, 2011 Hi Guys, i use julien breux horizontal navigation menu. I search a synchronized version of the block categories modul. My need is the following: If I select a category via the horizontal menu, only the selected category and it's subcategories should appear in the categories block in the left hook. Does anyone know a modul with this functionality or could give me some hints were I need to modify the modul? Merry Christmas to everyone and I appreciate any help. Thanks. Chris Link to comment Share on other sites More sharing options...
Snade Posted December 25, 2011 Share Posted December 25, 2011 Hi You can take the blocktopmenu from the 1.5 theme and itegrate it in your theme. Merry Christmas EDIT: sorry, I didn't read your post carefully. Solution in my next post Link to comment Share on other sites More sharing options...
herchri Posted December 25, 2011 Author Share Posted December 25, 2011 Hi Snade, thanks for you reply. I already have a horizontal top menu. I've attached a screenshot of my actual test template. I want to change the left categories block. If I select the category 'iPods' in the horizontal top menu, only iPods and it's 2 subcategories should appear in the left category list. Do you know how to change it? thanks and kind regards Chris Link to comment Share on other sites More sharing options...
Snade Posted December 26, 2011 Share Posted December 26, 2011 So, I came up with a solution but I cant get it fully working. The idea is to have display:none; on all <li> elements in the menu, and change that to display:block, for the selected category. It sounds easy, and it is if you dont have subcategories. So first I added display:none to the #categories_block_left li and display:block to #categories_block_left li ul li (when you have selected a main category, the subcategories need to show up) then I edited category-tree-branch like that <li {if isset($last) && $last == 'true'}class="last" {/if}{if isset($currentCategoryId) && ($node.id == $currentCategoryId)}style="display:block"{/if}> which just add style="display:block" to the <li> when this is the current category. works fine for the main categories. But when you select a subcategory, the parent category <li> no longer get display:block (which is perfectly normal when you think about it.... ) Somehow we have to link the currentcategoryid to the parent_id or something... Maybe someone else can give a clue how this can be achieved ? @herchri Change the name of the topic to "Block Categories - show only current category" or something like that. Probably it will drive more attention than just block categories Link to comment Share on other sites More sharing options...
herchri Posted December 26, 2011 Author Share Posted December 26, 2011 many thanks for you help. I tried editing where condition of the sql statement in the blockcategories.php, but I had no luck with it. Does anyone have other hints? Link to comment Share on other sites More sharing options...
herchri Posted December 26, 2011 Author Share Posted December 26, 2011 Do I understand the modul correctly? blockcategories.tpl delivers the main categories and category-tree-branch.tpl delivers the subcategories and highlights the active category ? Now I tried to add an 'if' condition in block categories.tpl , but I think I'm still on the wrong way ... I tried to add the following: {if isset($currentCategoryId) && ($node.id == $currentCategoryId)} {foreach from=$blockCategTree.children item=child name=blockCategTree} {if $smarty.foreach.blockCategTree.last} {include file="$branche_tpl_path" node=$child last='true'} {else} {include file="$branche_tpl_path" node=$child} {/if} {/foreach} {/if} Link to comment Share on other sites More sharing options...
Snade Posted December 26, 2011 Share Posted December 26, 2011 Both main categories and subcategories are generated in category-tree-branch. That is the problem, we need to make an if statement not only for current category, but for current category and its parent categories. Here is an idea, but I want you to try it since I dont have time. {if isset($id_category_parent) && ($node.id == $id_category_parent)}style="display:block"{/if} (this will not be the final code, just test it to see if its working for parent category) Link to comment Share on other sites More sharing options...
Snade Posted December 26, 2011 Share Posted December 26, 2011 It looks like we are doing it wrong by trying to trick this only with smarty. Probably there is a way to do it like that, but this guy here has done the job in the blockcategory.php file - http://www.prestashop.com/forums/topic/147686-solved-blockcategory-display-only-from-level1/ cheers Link to comment Share on other sites More sharing options...
herchri Posted December 26, 2011 Author Share Posted December 26, 2011 Sounds great ... I'll test it ... thanks Link to comment Share on other sites More sharing options...
herchri Posted December 26, 2011 Author Share Posted December 26, 2011 Ok, looks much better now. Great. Now I've only one issue. I want, that the label of the left categories box - at the moment 'Kategorien' - gets automatically exchanged by the highest parent category - in my example 'iPods' - Does anyone have an idea for this? Link to comment Share on other sites More sharing options...
herchri Posted December 30, 2011 Author Share Posted December 30, 2011 Does nobody have an idea? Link to comment Share on other sites More sharing options...
herchri Posted January 5, 2012 Author Share Posted January 5, 2012 Can anyone help me on this? Link to comment Share on other sites More sharing options...
Snade Posted January 5, 2012 Share Posted January 5, 2012 Hi check this topic to see if the solutions there work for you http://www.prestashop.com/forums/topic/117702-solved-display-parent-category-inside-a-category/ Link to comment Share on other sites More sharing options...
herchri Posted January 6, 2012 Author Share Posted January 6, 2012 Many thanks Snade ... I'll check it and maybe it pushs me in the right direction Link to comment Share on other sites More sharing options...
chuvachon Posted January 20, 2012 Share Posted January 20, 2012 That's how I solved it, using Snade's idea + javascript call to parent tags: 1) in category-tree-branch.tpl i wrote <li class="{if isset($last) && $last == 'true'}last {/if} menulist" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}id="currentli"{/if}> 2) add new javascript function in tools.js (it could be any .js file, called on your page) function changevisibility() { document.getElementById('currentli').parentNode.parentNode.id = "parid"; } 3) add in <body> tage on header.tpl: onload="changevisibility()" So this function will be called when our page is just loaded 4) add in global.css #categories_block_left li {display:none;} li#parid, li#parid #currentli, li#parid ul, li#parid ul li, #currentli, #currentli ul li{display: block !important;} 1 Link to comment Share on other sites More sharing options...
Guest masquemortal Posted October 1, 2013 Share Posted October 1, 2013 well thank you both for sharing that solution!, maybe will test it later on my shop, it could be usefull, thanks again Link to comment Share on other sites More sharing options...
uGoGo Posted October 1, 2013 Share Posted October 1, 2013 Did it solve your problem? Link to comment Share on other sites More sharing options...
Guest masquemortal Posted October 8, 2013 Share Posted October 8, 2013 last chuvachon solution for changing the name of categorie block title, didnt work for me. The other one solution for showing only parent categorie in block, works fine on 1.4.6.2 Link to comment Share on other sites More sharing options...
Shwamateur Posted September 25, 2014 Share Posted September 25, 2014 So I wouldn't say I solved this because it doesn't work for all cases. But I use this modified version of the blockcategories module. Since on my webpage the categories block is only displayed on category pages, this works good, but I know that it doesn't work properly on product pages. In order to solve this you should modify the getTree method on blockcategories_mod.php, assigning the initial category id (the one that conveniences you) to $id_category. I hope this is useful for somebody! blockcategories_mod.zip Link to comment Share on other sites More sharing options...
poorna Posted December 23, 2014 Share Posted December 23, 2014 I want to display the home categories for all pages in the left sidebar. It works fine. Then, For one of the category page I need to display the current category in the left sidebar. How can I do? How can I enable current category for one of the category page I have an idea. I have to change the home category to a current category for that particular category. But I don't know how to achieve using code? Can anyone help, please.. Link to comment Share on other sites More sharing options...
Recommended Posts