gloginko Posted April 1, 2014 Share Posted April 1, 2014 (edited) Hi, I'm encountering the following big problem: After a product or a subcategory of the main Categories menu is clicked and then i return to the home page - then the category menu (located on the left side of the page) stays open and displays the last visited product or subcategory. Instead of returning to its original state. For example: In its default state my Categories menu in the left side of the page looks like in the attached picture No. 1. But then on picture no.2 : it is visible that after browsing through some products or subcategories (in this case the subcategiry was "Blood Sugar") and returning to home page - the categories menu stays open on the last visited subcategory - respectively product, and did not return to it's original state (please compare pictures 1 and 2) Please advise a solution. My site is still a work in progress but is accessible on prestashop.herbalbg.com Thanks a lot Edited April 1, 2014 by gloginko (see edit history) Link to comment Share on other sites More sharing options...
prestashopninja Posted April 2, 2014 Share Posted April 2, 2014 Hi, I guess this post should be in development section. I don't think it's a bug but anyway, this feature is controlled by the variable $this->context->cookie->last_visited_category A possible solution would be to add a hook to homepage such as public function hookDisplayHome { unset($this->context->cookie->last_visited_category); } ...and register it in install() method. I hope this helps. Link to comment Share on other sites More sharing options...
gloginko Posted April 2, 2014 Author Share Posted April 2, 2014 Hi, Thanks a lot for taking time to reply to my post. Could you please advise the exact location of the file in which the above mentioned variable: $this->context->cookie->last_visited_category is located - is it global.css or any other file so i could give it a try. Link to comment Share on other sites More sharing options...
prestashopninja Posted April 2, 2014 Share Posted April 2, 2014 Hi, Sorry, I thought it was obvious. modules/blockcategories/blockcategories.php Link to comment Share on other sites More sharing options...
gloginko Posted April 3, 2014 Author Share Posted April 3, 2014 Hi Prestashop Apprentice, I'm deifnitely new to Prestashop thats' why such questions pop out. Sorry. Since a friend of mine who knows more about programming will try to implement the suggested changes - he urged me to calriify in my post that: The left categoryblock stays open (and also displays in its top part) the name of the last visited category/product not only on the Hompeage, but on all other pages where the category block is present. So do we need to put another variable or Is the suggested variable going to be sufficient for the change to also effect (the behaviour) and the way the category block on left side looks - in ALL OTHER pages where it is vissible as well, not onl on the Hompeage. Also he asked if would be possible to advise us what are the steps to add this "hook" to homepage - and does such hook need to be added for all other pages in which the category is present Thanks a lot again. i hope i did not mess things up further with the above "clarification" Link to comment Share on other sites More sharing options...
gloginko Posted April 3, 2014 Author Share Posted April 3, 2014 Hi, I just got the Product ctaegory block on left side to refresh and appear with the main Category "Tibetan Herbal Products" on all pages - in BO juse positioned the block above "News block" and after refreshing now it seems to be working properly, So kindly ignore my last post. The onyl issue left to address is: is there a way to make the category block refresh and display the first set of products subcategories As when the "+" sign is clicked. In the attached picture there is comparison between the way the category block displays at the moment and the way it needs to be displayed. Thanks a lot again Link to comment Share on other sites More sharing options...
prestashopninja Posted April 3, 2014 Share Posted April 3, 2014 (edited) Hi, Please open blockcategories.php file mentioned above and find this: public function hookHeader() inside this method, add the below, before everything: if(Context::getContext()->controller->php_self != 'category') unset($this->context->cookie->last_visited_category); so the whole method will look like in 1.5.6.2 (most probably this will be quite identical in your version as well) : public function hookHeader() { if(Context::getContext()->controller->php_self != 'category') unset($this->context->cookie->last_visited_category); $this->context->controller->addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); $this->context->controller->addCSS(($this->_path).'blockcategories.css', 'all'); } The moment you will make this change and run it, you will be free as a bird, so tell your friend to come another day Edited April 3, 2014 by prestashopninja (see edit history) Link to comment Share on other sites More sharing options...
gloginko Posted April 3, 2014 Author Share Posted April 3, 2014 Hi, thanks a lot for the constant help and spending so much time on this issue I have just implemented the code as per your instructions Currently the the blockcategories.php file looks like this: public function hookHeader() { if(Context::getContext()->controller->php_self != 'category') unset($this->context->cookie->last_visited_category); $this->context->controller->addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); $this->context->controller->addCSS(($this->_path).'blockcategories.css', 'all'); } I saved the changes in the file and copied the file back to replace the old blockcategories.php file that was on the server. But never the less there is no change in the way the Categories menu displays in the Front office. I cleared the cahce on the server and in my browser as well. Should other changes in different files be done as well - in order to have the prestashop server accept the changes that have been done to the blockcategories.php file ? Or copying the amended file to the server is enough ? If so - then what am i doing worng ? What does it mean and how can i "register it in install() method" ? Thanks a lot Link to comment Share on other sites More sharing options...
prestashopninja Posted April 3, 2014 Share Posted April 3, 2014 Well, I was so confident to tell you to tell your friend not to come Did you try it logging out and logging back in, as we are talking about the cookies? This issue shouldn't be rocket science. Link to comment Share on other sites More sharing options...
gloginko Posted April 3, 2014 Author Share Posted April 3, 2014 Hi, Finally we got a solution - thanks to your input and advise My friend put the advised parameters to the "left column" hook, instead of the public function hookHeader he then specified the ID number for the "Tibetan Herbal products" category and now the product category menu opens on the homepage and the rest of the pages exactly as we wanted it So huge thanks to you man Your support is greatly appreciated - 3 days have been spent in reading in the formus - so wihtout your input, i probably would have been on the 4th or 5th day of futile search for a solution Since you have been so accommodating for the last topic and problem , could you please advise if the following can be achieved: I'm creating few different CMS categories which will contain different CMS pages: The CMS categories will be visible on the main navigation bar Is it possible the pages that these categories will contain to be displayed as drop down menu - in vertical order ? Currently all CMS pages in a CMS category appear by default in horizontal way, right next to each other ? And since these CMS ctaegories will be displayed also on the left column - is it possible to make the sub-pages collapse and expand ? To have similar functunality as in the Product categories block : by pressing "+" sign - to expand and "-" sign to collapse ? Thanks a lot again Would it be Is it possible to display CMS category pages which will contain sub-pages in thempages in the top Link to comment Share on other sites More sharing options...
Recommended Posts