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 . '">';
}
}
Bookmarks