The cpg_die function is very good at passing error messages to the user but gives no choices for recovery. One example is when a user doesn't complete a comment form. Most users would (or should) know to use their back button. some might not. This is for the users who would not immediately press the browser's back button.
A simple snip added to your theme.php can give them a clickable message to go back.
Quotein your theme.php find<!-- END output_buffer -->
<br /><br />
Quoteand add below it<h1 align="center">
<a href="#" onclick="history.go(-1);return false;"><b><font color= "red">
CLICK HERE AND TRY AGAIN.</br></br>(OR USE THE BACK BUTTON ON YOUR BROWSER)</b></font></a>
</br>
</h1>
This style gives a red message with a large font, apply your own style as you like. Add a <noscript> message or
php return. This post here is just a starting suggestion.
It is now running here: gallery.josephcarver.com/natural/ (http://gallery.josephcarver.com/natural/)
(After making the change tonight I searched the board before posting, because I thought it was too obvious and that this might have been covered somewhere else, if so my apologies)
Thanks for your readiness to share.
In an ideal world, JavaScript-driven links should only show up if the user has got JavaScript enabled (people who don't know that there is a back-button in their browser probably won't know how to enable JavaScript). So, I'd do that with a document.write. Additionally, using the HTML font-tag is not recommended, as it will render your entire page invalid. CSS-styling should be applied instead.
Full set of instructions:
1) Edit themes/yourtheme/theme.php, find$template_cpg_die =
and edit as suggested below. If you can't find that piece of code in your custom theme, copy// HTML template used by the cpg_die function
$template_cpg_die = <<<EOT
<tr>
<td class="tableb" align="center">
<font size="3"><b>{MESSAGE}</b></font>
<!-- BEGIN file_line -->
<br />
<br />
{FILE_TXT}{FILE} - {LINE_TXT}{LINE}
<!-- END file_line -->
<!-- BEGIN output_buffer -->
<br />
<br />
<div align="left">
{OUTPUT_BUFFER}
</div>
<!-- END output_buffer -->
<br /><br />
</td>
</tr>
EOT;
from themes/sample/theme.php into a new line before ?>
of the file themes/yourtheme/theme.php
2) In the variable definition that you pasted into your custom theme in step 1, find<!-- END output_buffer -->
<br /><br />
and add after it into a new line<script type="text/javascript">
document.write('<span style="font-weight:bold;color:red;font-variant:small-caps;">Click <a href="#" onclick="history.go(-1);return false;">here</a> to go back and try again (or use the back button on your browser).</span>');
</script>
3) Save your changes and upload your custom theme file to your webserver.
Sadly, this will be with hard-coded language - a true internationalization would be much more complicated and would require editing core files.
Thanks for the reply and the corrections. I have now made it less textual and more visual by adding
three large back buttons from the images folder. The english text is also cut down.
<script type="text/javascript">
document.write('<a href="#" onclick="history.go(-1);return false;"><img src="images/prev.gif" alt=""
title="" border="0" width="20" height="20"><img src="images/prev.gif" alt="" title="" border="0" width="20"
height="20"><img src="images/prev.gif" alt="" title="" border="0" width="20" height="20"><span
style="font-weight:bold;color:red;font-variant:small-caps;"><br>GO BACK</a></span>');
</script>
From your answer I presume that this, as a language variable, cannot be used? (example from english.php)
$lang_back = 'BACK';
Thank you again
Quote from: i-imagine on April 29, 2009, 05:41:21 PM
From your answer I presume that this, as a language variable, cannot be used? (example from english.php)
$lang_back = 'BACK';
Not without editing include/functions.inc.php
Thank you. At the moment the only edits for me will be to a changelog. What you posted earlier is fine enough.