"back" Button On A Product Page

Hi,

Can’t understand how to do this:

User applied some filters on a category page and get some list of products. He enters a product page to view details and then goes to other filtered products with help of great next/previous navigation buttons that cs-cart have. But there is no ability for the user to return to the category page and not to lose all the filters applied.



I can get a current url in categories controller with the code ```php
Registry::get(‘config.current_url’)

Try make as in shippments:



{assign var="return_current_url" value=$config.current_url|escape:url}
{btn type="list" text=__("delete") class="cm-confirm" href="shipments.delete?shipment_ids[]=`$shipment.shipment_id`&redirect_url=`$return_current_url`"}

Thank you Cart-Power!

As I understand it right the specified button deletes a shipment and refreshes the page with the assigned redirect_url value, that is equal to the current page url. But in my example I need to remember the current url and pass it to another page and than use it there as a button or link (user is in categories controller and goes to the products controller). I can return him back with [font=Consolas,]cm-back-link [/font]microformat but it works with the first product page only. If user visits several pages via prev/next navigation it will not work the way I need. Or am I missing something?

Probably your method is to add the current url to the new url, so instead of usual

index.php?dispatch=products.view&product_id=1

user will have

index.php?dispatch=products.view&product_id=1&return_url=index.php&category_id=3

And then get the return_url value and assign it to the “back” button link. I will try it, though I thought there is a way to make it less noticeable for the user.

I make it work finally via php $_SESSION.

In categories.post.php via my_changes addon I have added


$_SESSION['category_return_url'] = Registry::get('config.current_url');




In products.post.php



if (!empty($_SESSION['category_return_url'])) {
Registry::get('view')->assign('category_return_url', $_SESSION['category_return_url']);
}





Now in my product template {$category_return_url} gives the desired url.

You can also try use $_SERVER['HTTP_REFERER'] value. It is always equal value of url of page is visited before.