bykrmom Posted May 28, 2009 Share Posted May 28, 2009 I had a need for my customers to return to the category they came from when viewing any product. In case anyone else has the same need, here is a simple fix. This code goes into the product.tpl file in your themes folder, at about line 243 (give or take a few lines). {l s='Back to Category'} Add it just after quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p> {if $HOOK_PRODUCT_ACTIONS} {$HOOK_PRODUCT_ACTIONS} {/if} and before the </form> Not brilliant code, but it works. I couldn't find anything like this when I searched the site before I wrote this. If it's a duplication, sorry about that. Link to comment Share on other sites More sharing options...
San Diego Posted May 28, 2009 Share Posted May 28, 2009 good ideathanks for sharingsd Link to comment Share on other sites More sharing options...
cerberus22 Posted May 28, 2009 Share Posted May 28, 2009 Hi bykrmom,I have tried it and it puts the link words "Back to Category" in ok, but it does not work (it is not clickable) how do I fix this ?any ideas ?All the best,Cerberus22 Link to comment Share on other sites More sharing options...
bykrmom Posted September 9, 2009 Author Share Posted September 9, 2009 I just now saw that this didn't work for you, cerberus22... I apologize for not checking back.I have just tried 6 different ways to paste the code for my back to category button, but it won't post in the forum here. I'm wrapping it up in a text file, and zipping it to attach it to this post.open the file, unzip the text, and add it where I showed in my original post. Sorry for the delay. back-to-category-code.zip Link to comment Share on other sites More sharing options...
mel- Posted September 28, 2010 Share Posted September 28, 2010 does anyone know how to edit this code to say the name of the category? Right now it says "Back to category" but I'd like it to say the name of the category you came from. if it were Computer then it would say Back to Computers. If it were printers I'd like it to say Back to Printers.Also, I put this right below the breadcrumb instead just to put it at the top of the product page. I am going to (eventually) eliminate the breadcrumb entirely on the product page to reduce clutter but I want this back to button working first.thanks bykermom for this code! {l s='Back to Category'} I couldn't get the code to display right either ! on the above code you need to add the letters "on" in front of click to make the code work right. just won't display in the forums for some reason. Link to comment Share on other sites More sharing options...
Never_give_up Posted January 7, 2012 Share Posted January 7, 2012 paste the below code right after {$HOOK_PRODUCT_ACTIONS}{/if} on product.tpl from themes folder. <p class="buttons_bottom_block"><a onClick="history.go(-1);" class="button" onClick="history.go(-1);">{l s='Back to Category'}</a></p> 1 Link to comment Share on other sites More sharing options...
musicmaster Posted January 12, 2012 Share Posted January 12, 2012 I wrote some code for lnks to the category page. You can add this code to the template page. This will also take you to the category when you didn't come from the category page. The code supposes that you have url-rewrite enabled For the homepage this will work: {if $product.id_category_default != 1} {* exclude home page *} <i><a href="{$product.id_category_default}-{$product.category}/">more {$product.category_default}</a></i> {/if} For the product page it will be something like this: <i><a href="{$product->id_category_default}-{$product->category}/">more {$product->category}</a></i> Note that you have to use a different notation and that "category_default" field is not available. Link to comment Share on other sites More sharing options...
praneth Posted February 24, 2013 Share Posted February 24, 2013 Excellent! Thank you Link to comment Share on other sites More sharing options...
paotxdju0 Posted February 25, 2013 Share Posted February 25, 2013 Muchas gracias por adelantado, Link to comment Share on other sites More sharing options...
silentRun Posted May 31, 2013 Share Posted May 31, 2013 (edited) For the product page it will be something like this: <i><a href="{$product->id_category_default}-{$product->category}/">more {$product->category}</a></i> Note that you have to use a different notation and that "category_default" field is not available. In my case this link worked better: <i><a href="../{$product->id_category_default}-{$product->category}/">more {$product->category}</a></i> In order to redirect correctly to the previous category ( prestashop 1.5.4.1 ) Thanks a lot for the info !! Edited May 31, 2013 by silentRun (see edit history) Link to comment Share on other sites More sharing options...
Arganoid Posted October 7, 2013 Share Posted October 7, 2013 In my case this link worked better: <i><a href="../{$product->id_category_default}-{$product->category}/">more {$product->category}</a></i> In order to redirect correctly to the previous category ( prestashop 1.5.4.1 ) Thanks a lot for the info !! I tried this option and it works well especially if you have product attributes. Thank you very much! The only problem is if you have a product in two categories, then choose one at random. How could I fix it? Link to comment Share on other sites More sharing options...
Recommended Posts