Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,474
    Plugin Contributions
    88

    Default zen_back_link: addon problem when current page removed

    Running ZC 1.3.9h with various add-ons.

    I'm playing with the ask_a_question add-on and figured that there was no good reason to keep that page in the navigation history, so I updated the header_php.php file for the ask_a_question page to remove the page from the navigation history:

    Code:
    $_SESSION['navigation']->remove_current_page();
    So far, so good. The problem is that the function zen_back_link makes the "assumption" that the current page is in the navigation history and falls down the default "back-button" path in this case, resulting in the HTTP_REFERER being used; this unfortunately results in the "back" button for the ask_a_question "success" path going back the the ask_a_question page (erggh).

    Anyway, here's an updated version of zen_back_link() that is "aware" of the fact that the current page might not be present in the history list:
    Code:
    ////
    // Set back button
      function zen_back_link($link_only = false) {
    	// ----
    	// If the last page in the navigation history is the current page, then "back" is the previous
    	// page; otherwise, the current page has been removed from the navigation, so the "back" target
    	// is the last page in the navigation history.
    	//
    	$back = sizeof($_SESSION['navigation']->path) - 1;
    	if ($back > 0 && $_SESSION['navigation']->path[$back]['page'] == $_GET['main_page']) {
    	  $back--;
    	}
    //    if (sizeof($_SESSION['navigation']->path)-2 >= 0) {
    //      $back = sizeof($_SESSION['navigation']->path)-2;
        if ($back >= 0) {
          $link = zen_href_link($_SESSION['navigation']->path[$back]['page'], zen_array_to_string($_SESSION['navigation']->path[$back]['get'], array('action')), $_SESSION['navigation']->path[$back]['mode']);
        } else {
          if (isset($_SERVER['HTTP_REFERER']) && preg_match("~^".HTTP_SERVER."~i", $_SERVER['HTTP_REFERER']) ) {
          //if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], str_replace(array('http://', 'https://'), '', HTTP_SERVER) ) ) {
            $link= $_SERVER['HTTP_REFERER'];
          } else {
            $link = zen_href_link(FILENAME_DEFAULT);
          }
          $_SESSION['navigation'] = new navigationHistory;
        }
    	
        if ($link_only == true) {
          return $link;
        } else {
          return '<a href="' . $link . '">';
        }
      }

  2. #2
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: zen_back_link: addon problem when current page removed

    Hi,

    Not sure why you removed the page from the history in the first place, regardless this is not something we will be addressing at the moment, given it relates to an addon, and not core functionality.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,474
    Plugin Contributions
    88

    Default Re: zen_back_link: addon problem when current page removed

    Although this problem surfaced when I was configuring an add-on, I believe that it is a core-file issue. There are places in the stock Zen-cart install where the page "should" be removed from the navigation (like the logoff page) and the behavior of zen_back_link will continue to produce interesting results until it is corrected.

 

 

Similar Threads

  1. search admin page keys addon problem
    By michelleodin in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 13 Jan 2014, 03:06 PM
  2. v139h Store Credit addon problem - does not complete order when using coupon to zero
    By AvaAdorn in forum All Other Contributions/Addons
    Replies: 13
    Last Post: 23 Oct 2012, 03:14 AM
  3. Problem integrating additional image titles addon and commercial addon
    By strugglingnovice in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 15 Aug 2010, 03:07 PM
  4. restricted coupon not removed when allowable product removed
    By lexxymark in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 11 Aug 2010, 10:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR