HELP! Return to List button

Hi there,

I am hoping someone can help me here since the CS Cart team is too busy to help me. On all my product detail pages, I have a Return button that brings the user from the product back to the list. CS-Cart supplied me this code, but they didn't take into account if the category was split up over several pages of products. So what happens is if the user is on page three of the product listing pages and clicks to view a product, the Return button brings the user back to the top of page 1, losing their space. In theory, they should return to the page they left off and at the position on the page of the product (or in the least to the page they left off).



This is the code they gave me:



{assign var="back_url" value="$index_script?dispatch=categories.view&category_id=`$product.main_category`"}
{$lang.go} {$lang.back|lower}




Can anyone please help me adjust this? I'm willing to pay you for your time.



**Edit: FYI, same issue with breadcrumbs… it brings user back to page 1 instead of page they clicked from.

You might try:


{assign var="back_url" value="$index_script?dispatch=categories.view&category_id=`$product.main_category`&page=1"}
{$lang.go} {$lang.back|lower}

This may seem a little dumbfounding, but why not make it much simpler:


Return



This in effect returns the customer to the previously loaded page and only within your site (ie. will not return the customer back to a search engine results page).

Mixing ajax pagination with history may not give the desired results. I.e. this might take them back to the home page since the last “loaded” page was the 1st page of the category listing.

Hi guys -

First, thank you so much for replying. I really appreciate your help.



Tbirnseth, thanks for the mod to the code, but I need it to be dynamic. The “&page=1” brings it back to page 1, as it says. So if I'm on page 5, click into a product, I need it to return to page 5 (and preferably to the location of the product within the listing).



StellarBytes - yeah, I thought of that too, except the problem is if they arrive at the product not from the product listing page. Thanks for the thought though!!

Then do the math on the $smarty.request.page and subtract 1 and use that as the page number…



I thought the problem was you wanted them to return to page 1 and not the prior page…



You have the info on what to do now so you'll just have to experiment to get the results you're looking for.

No sorry, the code I was and AM using did go to the first page correctly. It wasn't until I set the products page to display a certain amount at a time that I ran into this issue (it was previously set to show all products in the category at once). I want it to dynamically return to the page the product it's listed on. So if I click from product listing page 5 into the product detail view, I want to click a button to return to the list, but at the spot I left off. It keeps kicking me back to page one, resulting in having to remember which page I was on to keep going through the list. Sorry if I wasn't clear. Does that make sense now?



So, in regards to your reply, I'm not sure what you mean when you say do the math on the $smart.request.page… I hate to ask you to explain, but if you had a moment I would love to understand how that applies.



Thanks Tbirnseth.

No way to do it from where you are without capturing the 'reffering url' and then parsing it out for the button.



Sorry, but I don't have time to figure it out right now but the jist is that you're going to want to capture

$smarty.server.HTTP_REFERRER and use that as the URL for your link. Though without investigation, that could result taking you back to page 1 also since they do pagination via ajax requests…

Ah, I see. OK, this is indeed way over my head. Would you happen to know how other people work around this issue? It seems to be a bit of a flaw in the navigation of the system, no? Just curious your thoughts on this…



Thank you so much for taking the time to try to help me - I really do appreciate it.








[quote name='tbirnseth' timestamp='1320194638' post='125128']

No way to do it from where you are without capturing the 'reffering url' and then parsing it out for the button.



Sorry, but I don't have time to figure it out right now but the jist is that you're going to want to capture

$smarty.server.HTTP_REFERRER and use that as the URL for your link. Though without investigation, that could result taking you back to page 1 also since they do pagination via ajax requests…

[/quote]

Not sure I'd call it a flaw…

I don't know what others might do. Since I don't recall seeing this as an issue, I'm guessing it's never been addressed.

Maybe I'm just missing something then. At any rate, thanks so much for your help. If anyone else has any suggestions I'm all ears! Thanks a bunch!




[quote name='tbirnseth' timestamp='1320197032' post='125135']

Not sure I'd call it a flaw…

I don't know what others might do. Since I don't recall seeing this as an issue, I'm guessing it's never been addressed.

[/quote]

Is there anybody that might be able to help me? I'm trying to figure out how to incorporate the $smarty.server.HTTP_REFERRER as Tbirnseth recommended, but it's failing each time as my smarty capabilities are next to none…