Jump to content

(fixed!) A back to category button for the product focus page (product.tpl)


Recommended Posts

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

  • 3 months later...

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

  • 1 year later...

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

  • 1 year later...

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

  • 1 year later...
  • 3 months later...

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 by silentRun (see edit history)
Link to comment
Share on other sites

  • 4 months later...

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

×
×
  • Create New...