a8e is a w3c compliant, open source, content management framework..

About the "Back" button

(1 vote)
Written by Laurent Belloeil Thursday, 29 March 2007

I hacked the /includes/joomla.php file to replace the JS function for a real <a> link when it is possible.

This is not a good solution because it is in a Core file. It is defined by the "BackButton" unction of the "mosHTML" class and this finction is called in many files.

The PECL library offer the ability to redefine a class function by using the runkit function but it is not available from all hosters :( 

Here is my solution :

function BackButton ( &$params, $hide_js=NULL ) {
// Back Button
if ( $params->get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) {
// ------------------------ A8E fixes start ------------------------
$HTTPReferer
= trim($_SERVER['HTTP_REFERER']);
$HTTPhost
= trim($_SERVER['HTTP_HOST']);
$queryString
= trim($_SERVER['QUERY_STRING']);
$PHPself
= rtrim($_SERVER['PHP_SELF'], "/\\");
$actual = "http://$HTTPhost$PHPself";
if ($queryString != ''){$actual .= '?'.$queryString;}
if (
$HTTPReferer == ''
OR
$HTTPReferer == $actual )
{
$back_link = 'javascript:history.go(-1)';
}else{
$back_link = $HTTPReferer;
}
?>
<div class="back_button">
<a href=<?php echo $back_link ?>>
<?php echo _BACK; ?></a>
</div>
<?php
// ------------------------ A8E fixes end ------------------------
}
}

Of course this is only a suggestion that have to be tested.

Last Updated ( Friday, 22 February 2008 )