Elcon_D 0 Posted January 5, 2010 Posted January 5, 2010 Hi,Firstly thanks for the solutions and modules to the good people that work for the community, it has been very useful to read these threads since I started to work with Prestashop. Today I encourage myself to write and ask you because I have a problem that is driving me crazy, changing code here and there..I want to show a module block only in one category and keep it hidden in the rest. The first thing I tried was easy, I went to "positions" in "modules" and I added "category.php" as exception . Obviously the block disappeared in all categories. After that I tried adding "category.php" with modifiers, (for example, "category.php? Id_category = 24") ... but id didn't work, the block displays normally this way. I've seen some thread where somebody was asking for something similar ( add as exception in the module individual pages of CMS (eg: instead of putting the exception "cms.php" put "cms.php? Id_cms = 2"), but no solution was encountered.The question is:Does anybody know, or comes up with a way for a block module to appear in some categories and keep hidden in on others?I tend to think that some lines of code can solve this, but my programming skills are quite limited...Thank you very much in advance! Share this post Link to post Share on other sites
rocky 958 Posted January 5, 2010 Posted January 5, 2010 You could add the following to the top of a block's tpl file: {if $smarty.get.id_category == 2} and the following to the bottom: {/if} This will make the block only display on the category 2 page. Share this post Link to post Share on other sites
Elcon_D 0 Posted January 5, 2010 Posted January 5, 2010 You could add the following to the top of a block's tpl file: {if $smarty.get.id_category == 2} and the following to the bottom: {/if} This will make the block only display on the category 2 page. So easy! Thank you Rocky !!! Share this post Link to post Share on other sites
metta 0 Posted January 6, 2010 Posted January 6, 2010 How about I only want the module display in category 2, 3, and 4 ? Share this post Link to post Share on other sites
rocky 958 Posted January 6, 2010 Posted January 6, 2010 Change the first line above to: {if $smarty.get.id_category == 2 OR $smarty.get.id_category == 3 OR $smarty.get.id_category == 4} Share this post Link to post Share on other sites
patadura 0 Posted January 29, 2010 Posted January 29, 2010 sorry for my poor English, but I can say in that module are those instructions.ThanksEspañol: perdon por mi poble inglés, pero podrias decirme en que modulo van esas instrucciones?gracias Share this post Link to post Share on other sites
rocky 958 Posted January 29, 2010 Posted January 29, 2010 These instructions can apply to any module that uses a TPL to display itself on the Front Office. Share this post Link to post Share on other sites
pjdj266 0 Posted October 4, 2010 Posted October 4, 2010 Hi guys, i have a questions in a similar area......how would i go about displaying the categories block on all category pages, except the main one? IE all pages except category.php?id_category=1The exception function only seems to allow you to put a page, IE category.php as an optionAny help is massively appreciated! Share this post Link to post Share on other sites
rocky 958 Posted October 4, 2010 Posted October 4, 2010 It's not possible to do that using exceptions. You must modify code. For example, edit modules/blockcategories/blockcategories.tpl and add the following to the top: {if $smarty.get.id_category != 1} and the following at the bottom: {/if} 1 Share this post Link to post Share on other sites
pjdj266 0 Posted October 4, 2010 Posted October 4, 2010 Great! that worked for the categories bloc. Thank you. Im trying to do this with the newletter v1.4 as well... IE so it doesnt appear on the category 1 page ....it doesnt seem to have a tpl file though? Any experience with this module? Share this post Link to post Share on other sites
rocky 958 Posted October 4, 2010 Posted October 4, 2010 It is modules/blocknewsletter/blocknewsletter.tpl. Share this post Link to post Share on other sites
pjdj266 0 Posted October 5, 2010 Posted October 5, 2010 Perfect, thank you! Share this post Link to post Share on other sites
x3n0m0rph 10 Posted January 16, 2011 Posted January 16, 2011 how can i make module products category 1.2 not to show on products from one category? Share this post Link to post Share on other sites
rocky 958 Posted January 17, 2011 Posted January 17, 2011 Edit modules/productscategory/productscategory.php and change lines 53-54 from: if (!$category->active) return; to: if (!$category->active OR $category->id == 2) return; Change 2 to the ID of the category you don't want the "In the same category" section to appear on. Share this post Link to post Share on other sites
x3n0m0rph 10 Posted January 19, 2011 Posted January 19, 2011 rocky, you are the best! thx Share this post Link to post Share on other sites
jjancke 1 Posted January 20, 2011 Posted January 20, 2011 Thank you rocky for posting this! Works like a charm. But to concerns: As I want the blockcart not shown on homepage and all cms-pages, I was trying this: {if $smarty.get.id_cms != 7 OR $smarty.get.id_category != 8} This is producing an error in lines, which aren't affected? When I reduce my coding to {if $smarty.get.id_cms != 7} it works. Any Ideas?And - how should I adress the homepage, wch isn't a cms nor a category?Thanks for helping,jens Share this post Link to post Share on other sites
jjancke 1 Posted January 20, 2011 Posted January 20, 2011 Maybe, I should think a little longer ...I've got it working this way:Let's say, the lowest number of my categories is 3, then my code is {if $smarty.get.id_category > 3} So now, as the cms-pages are not categories as well as the homepage the blockcart appears only on productpages;)jens 1 Share this post Link to post Share on other sites
rocky 958 Posted January 20, 2011 Posted January 20, 2011 Try: {if $page_name != 'index' AND $page_name != 'cms'} 1 Share this post Link to post Share on other sites
jjancke 1 Posted January 20, 2011 Posted January 20, 2011 You're the heroe;) 'page_name' was the key.Thanks a lot for helping,jens Share this post Link to post Share on other sites
yamzalal 0 Posted July 15, 2011 Posted July 15, 2011 is it possible to display Categories block in all products related to one category? I am able to display only in one category but also wanted to display it in the products that are tagged to that category.Please help me on this Share this post Link to post Share on other sites
vivek.sakhilati 1 Posted July 1, 2013 Posted July 1, 2013 Hi Rocky, This works like charm... But i have a problem, i have more than 350 categories this code " {if $smarty.get.id_category == 2 OR $smarty.get.id_category == 3 OR $smarty.get.id_category == 4} " is not workign for many categories more than 25. What exactly i need is i want to show category blocks for categories between Id no's 135 and 235. How to acheive it ? Share this post Link to post Share on other sites
madgik 0 Posted February 28, 2014 Posted February 28, 2014 Hi Thanks Rocky ! you really the best. Is there any way to show a block that is on product page only for some products of some categories ??? Share this post Link to post Share on other sites
mokadik 0 Posted August 17, 2014 Posted August 17, 2014 (edited) [solved] Hello. I need blocknewproducts no show in index. I probe in tpl files insert: {if $page_name != 'index' AND $page_name != 'cms'} .... ....(original content) .... {/if} but don't work. it is showed in "start" page always. How to remove it from start page. Please. SOLUTION: prestashop 1.6 have hooks for home page. thanks Edited August 17, 2014 by mokadik (see edit history) Share this post Link to post Share on other sites
vekia 8,966 Posted August 17, 2014 Posted August 17, 2014 modules > positions search for module on each available list there, click on edit button and define exception for that module, you can select "index" (homepage) and module will not appear there anymore 1 Share this post Link to post Share on other sites
mokadik 0 Posted August 17, 2014 Posted August 17, 2014 modules > positions search for module on each available list there, click on edit button and define exception for that module, you can select "index" (homepage) and module will not appear there anymore Yes that is. I was modify the post with solution. Thanks. Thanks. Share this post Link to post Share on other sites
panutsonline 1 Posted February 6, 2015 Posted February 6, 2015 Hi Rocky, This works like charm... But i have a problem, i have more than 350 categories this code " {if $smarty.get.id_category == 2 OR $smarty.get.id_category == 3 OR $smarty.get.id_category == 4} " is not workign for many categories more than 25. What exactly i need is i want to show category blocks for categories between Id no's 135 and 235. How to acheive it ? Hi, vivek.sakhilati did you solve your problem? If so, would you mind sharing how please? Thanks Share this post Link to post Share on other sites
Totti 59 Posted February 6, 2015 Posted February 6, 2015 $smarty.get.id_category retrive value from query string ? Share this post Link to post Share on other sites
Recommended Posts