Suggested update to print function
Posted: Thu Jun 15, 2006 9:42 pm
I think this change in the print function is a little more elegant than the way it is currently implemented.
The way the print function works now is if you choose the showbutton option you get the same button on the actual web page as well as on the printable page, and they both do the same thing -- bring up another popup (if you use that option) or bring up another printable page--ad infinitum. If you use text instead of the button you get "Print this page," which is NOT what that link actually does. Instead, it brings up a "printable version" of the page -- ad infinitum.
So my suggestion (and rough solution below) is to make the first block of text say "Printable Version" which, when cliked, brings up the printable version, and the text on the printable version page says "Print" which, when clicked, brings up the print dialog box.
if you use "showbutton" then the first button brings up the ptintable version and the second brings up the print dialog.
Here's how I changed it:
line 23-24:
lines 55-76:
I also edited the help section so that the english actually makes sense:
Finally, there's an issue with the CSS. Currently the content is wrapped only in the body tag, which in the default templates uses text-align: center so that everything on the printable page is center-aligned. Can you add a parameter like divid="" so you manually choose a style to wrap {content} in?
Thanks!
The way the print function works now is if you choose the showbutton option you get the same button on the actual web page as well as on the printable page, and they both do the same thing -- bring up another popup (if you use that option) or bring up another printable page--ad infinitum. If you use text instead of the button you get "Print this page," which is NOT what that link actually does. Instead, it brings up a "printable version" of the page -- ad infinitum.
So my suggestion (and rough solution below) is to make the first block of text say "Printable Version" which, when cliked, brings up the printable version, and the text on the printable version page says "Print" which, when clicked, brings up the print dialog box.
if you use "showbutton" then the first button brings up the ptintable version and the second brings up the print dialog.
Here's how I changed it:
line 23-24:
Code: Select all
global $gCms;
$text = 'Printable Version';
$print = 'Print';
Code: Select all
if (isset($params["showbutton"]))
{
if ($_GET['print'])
{
return '<a href="javascript:window.print();"><img src="'.$gCms->config['root_url'].'/images/cms/printbutton.gif" alt="'.$text.'"/></a>';
}
else
{
return '<a href="'.$gCms->config['root_url'].'/index.php?page='.$gCms->variables['content_id'].'&print=true' . $goback . $js . '"'. $target . '><img src="'.$gCms->config['root_url'].'/images/cms/printbutton.gif" alt="'.$text.'"/></a>';
}
}
else
{
if ($_GET['print'])
{
return '<a href="javascript:window.print();">'.$print.'</a>';
}
else
{
return '<a href="'.$gCms->config['root_url'].'/index.php?page='.$gCms->variables['content_id'].'&print=true' . $goback . $js . '"'. $target . '>'.$text.'</a>';
}
}
Code: Select all
<li><em>(optional)</em>goback - Set to "false" and in print page you won't see the "Go Back" button.</li>
<li><em>(optional)</em>popup - Set to "true" and printable page will by opened in new window.</li>
<li><em>(optional)</em>script - Set to "true" and printable page will automatically bring up the print dialog box using javascript.</li>
<li><em>(optional)</em>showbutton - Set to "true" and will show a printer graphic instead of a text link.</li>
Thanks!