Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / How to link "Back to Product List" button back to last page history

How to link "Back to Product List" button back to last page history

Started by sports_guy on 7 Feb 2014, 3:03 AM · Views: 1,456

Results 1 to 4 of 4
7 Feb 2014, 3:03 AM
#1
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #1 by sports_guy

I have a client who has many products. Problem is when viewing a product and you click the "Back to Product List" you are taken back to page 1 at the top of the page. It would be better if you could return to the page you were previously viewing (or to same area of the multiple product list which is the same page and product you are viewing).

In his case if you are on page 5 and you click a product for detail, and then when you click "Back to Product List" it would be nice to go back to page 5 of the multiple product list. Not all the way back to the very top of page 1 again.

I have read these posts: http://www.zen-cart.com/showthread.php?93024-How-to-link-quot-Product-List-quot-button-back-to-last-page-history&highlight=back+product+list and http://www.zen-cart.com/showthread.php?109880-Category-Page-Sessions

Wish Zen Cart would give us a setting like: take back to first product or take back to same product page in multiple products view, that pertains to this list.

It seems like this never got addressed. This seems to be a re-occuring issues others are having. Years later I am seeking the same answer. Does anyone have an answer for this as of yet?

Building a better web, one site at a time: Dayton Web Design

9 Feb 2014, 5:50 AM
#2
noellas avatar

noellas

New Zenner

Join Date:
Feb 2014
Location:
Markham, Ontario, Canada
Posts:
5
Plugin Contributions:
0

Post #2 by noellas

One way to do this would be with HTML (change what the button does in the places it appears in the files).

I did a search for "html for back button" - it is Javascript based (so client side - they can have it off) - and it depends on using the browser history - if they arrived at the page by search engine or bookmark it will not work. There are easily half a dozen useful relevant links on the first page (W3Schools etc).

The other way to do it would be with PHP

<?php
  $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
  echo "<a href='$url'>back</a>"; 
?>

The question is, the browser already has this built in - are you trying to provide a different function to the browser back button?

9 Feb 2014, 7:36 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #3 by mc12345678

sports guy:

I have a client who has many products. Problem is when viewing a product and you click the "Back to Product List" you are taken back to page 1 at the top of the page. It would be better if you could return to the page you were previously viewing (or to same area of the multiple product list which is the same page and product you are viewing).

In his case if you are on page 5 and you click a product for detail, and then when you click "Back to Product List" it would be nice to go back to page 5 of the multiple product list. Not all the way back to the very top of page 1 again.

I have read these posts: http://www.zen-cart.com/showthread.php?93024-How-to-link-quot-Product-List-quot-button-back-to-last-page-history&highlight=back+product+list and http://www.zen-cart.com/showthread.php?109880-Category-Page-Sessions

Wish Zen Cart would give us a setting like: take back to first product or take back to same product page in multiple products view, that pertains to this list.

It seems like this never got addressed. This seems to be a re-occuring issues others are having. Years later I am seeking the same answer. Does anyone have an answer for this as of yet?

In looking at data captured by superglobals, there is some back information that is captured at least for two levels inside of Zen Carts data. That said, should be able to test if there is no back data associated with a desired location, then to behave a certain way.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Feb 2015, 10:11 AM
#4
vandijkstef avatar

vandijkstef

New Zenner

Join Date:
Feb 2014
Location:
Amsterdam, Netherlands
Posts:
9
Plugin Contributions:
0

Post #4 by vandijkstef

Been looking for this. Ended up coding something myself, maybe someone has good use with this:

$pathlength = count($cPath_array);
$pathcount = 1;
$category_url = '';
foreach($cPath_array as $catID) {
  $category_url .= $catID;
  if ($pathcount < $pathlength && $pathlength > 1) {
    $category_url .= '_';
  }
  $pathcount++;
}
echo '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_url) . '">Terug</a>';