Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: All Themes - Error Recovery and Return for Users - cpg_die page  (Read 5492 times)

0 Members and 1 Guest are viewing this topic.

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page

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.

Quote
in your theme.php find
Code: [Select]
<!-- END output_buffer -->
                        <br /><br />
Quote
and add below it
Code: [Select]
<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/

(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)

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: All Themes - Error Recovery and Return for Users - cpg_die page
« Reply #1 on: April 29, 2009, 08:24:52 am »

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
Code: [Select]
$template_cpg_die =and edit as suggested below. If you can't find that piece of code in your custom theme, copy
Code: [Select]
// 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
Code: [Select]
?>of the file themes/yourtheme/theme.php

2) In the variable definition that you pasted into your custom theme in step 1, find
Code: [Select]
<!-- END output_buffer -->
                        <br /><br />
and add after it into a new line
Code: [Select]
<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.
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: All Themes - Error Recovery and Return for Users - cpg_die page
« Reply #2 on: April 29, 2009, 05:41:21 pm »

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.
Code: [Select]
<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)
Code: [Select]
$lang_back = 'BACK';Thank you again


Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: All Themes - Error Recovery and Return for Users - cpg_die page
« Reply #3 on: April 29, 2009, 10:12:14 pm »

From your answer I presume that this, as a language variable, cannot be used?  (example from english.php)
Code: [Select]
$lang_back = 'BACK';
Not without editing include/functions.inc.php
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: All Themes - Error Recovery and Return for Users - cpg_die page
« Reply #4 on: April 29, 2009, 10:27:39 pm »

Thank you. At the moment the only edits for me will be to a changelog. What you posted earlier is fine enough.
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 19 queries.