dramdram Posted May 2, 2012 Share Posted May 2, 2012 Hi all of you, I am desperately trying to have all product categories as links displayed on my product page. It would look as on this page where you can read "Found in: Gadgets & Tools ....." I have found the function "getProductCategories" which should be the right one. The thing is i don't know how to make it work through the product.php, product.tpl and productcontroller.php. I thank you in advance for any help on that topic. Link to comment Share on other sites More sharing options...
phrasespot Posted May 4, 2012 Share Posted May 4, 2012 (edited) Do not touch product.php or productcontroller.php. The information you require is already passed to product.tpl. You can do something like the following at the location you want output displayed in product.tpl: <p>This product appears in: {foreach $categories as $category} <a href="{$category['link_rewrite']}">{$category['name']}</a>{if !$category@last} |{/if} {/foreach}</p> Edited May 4, 2012 by phrasespot (see edit history) 1 Link to comment Share on other sites More sharing options...
dramdram Posted May 5, 2012 Author Share Posted May 5, 2012 Thank you for your help. But it unfortunately crashes ... Are you sure it is not the getproductcategories variables which needs to be called in the tpl ? Link to comment Share on other sites More sharing options...
phrasespot Posted May 5, 2012 Share Posted May 5, 2012 (edited) Are you sure Yes I am, but I assumed you are using the latest version. If you are using an earlier version that may matter. getproductcategories is a class method and has no business in a tpl file Edited May 5, 2012 by phrasespot (see edit history) 1 Link to comment Share on other sites More sharing options...
dramdram Posted May 5, 2012 Author Share Posted May 5, 2012 Ok, I am using version PrestaShop™ 1.4.7. I may have a solution which is on that page, i have tested it: http://www.prestashop.com/forums/topic/139200-display-categories-to-which-product-belongs-in-product-detail-page/page__p__816472#entry816472 It works (by the way, I did took off all the scripts from it to test your solution). That one unfortunately only display categories as name, ca you maybe help me to have it displayed as links ? Thanks for your help Link to comment Share on other sites More sharing options...
phrasespot Posted May 5, 2012 Share Posted May 5, 2012 Ok, I am using version 1.4.7 Then it should work. Make sure you are not making a syntax error when copying to location and using Smarty 3, not 2 (BO > Preferences > Use Smarty 2 instead of 3 = no) 1 Link to comment Share on other sites More sharing options...
dramdram Posted May 5, 2012 Author Share Posted May 5, 2012 (edited) Well it worked but now i get problems on other pages ... Edited May 5, 2012 by dramdram (see edit history) Link to comment Share on other sites More sharing options...
dramdram Posted May 5, 2012 Author Share Posted May 5, 2012 ... Link to comment Share on other sites More sharing options...
phrasespot Posted May 5, 2012 Share Posted May 5, 2012 (edited) Well it worked but now i get problems on other pages ... Then your theme (or some 3rd party modules you use) must be incompatible with Smarty 3. No matter. change the snippet I posted to following (using Smarty 2 syntax): <p>This product appears in: {foreach item=cat name=cats from=$categories} <a href="{$cat.link_rewrite}">{$cat.name}</a>{if !$smarty.foreach.cats.last} |{/if} {/foreach}</p> Edited May 5, 2012 by phrasespot (see edit history) Link to comment Share on other sites More sharing options...
dramdram Posted May 6, 2012 Author Share Posted May 6, 2012 ... well i works but it now displays the main categories and not the one related to the products ... i am sorry Link to comment Share on other sites More sharing options...
phrasespot Posted May 6, 2012 Share Posted May 6, 2012 I am desperately trying to have all product categories as links displayed on my product page. Answered as asked 1 Link to comment Share on other sites More sharing options...
dramdram Posted May 6, 2012 Author Share Posted May 6, 2012 Link to comment Share on other sites More sharing options...
nuacco Posted January 3, 2013 Share Posted January 3, 2013 i also need the code, where it outputs all sub categories (NOT categories), where the product is in Link to comment Share on other sites More sharing options...
threeopus3 Posted May 11, 2013 Share Posted May 11, 2013 (edited) <p>This product appears in: {foreach $categories as $category} <a href="{$category['link_rewrite']}">{$category['name']}</a>{if !$category@last} |{/if} {/foreach}</p> Phrasespot, this displays all categories that exist in your shop. It does not display the categories that a product belongs to. Just an FYI. Still a useful peice of code. Edited May 11, 2013 by threeopus3 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now