Topic: [HACK] Printer - Friendly URLS for News
Name: Printer - Friendly URLS for News
Author: John/Will
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Would you like your articles to be printer-friendly ? Do you post a lot of news you deem for others to be worth printing out and they feel a need to print almost every news topic from your website no matter the cause but they're STILL on Dot Matrix Printers?
Dont worry my friends, help is at hand! ... Flexer has wrote an ingenius way to make your pages Printer friendly, this was used for earlier versions of Cutenews but it should still be relevant to this day.
An alternative can be found here
Download: get the hack here
Instructions:
Save this as "print.php" and put it in the CuteNews root folder.
<?PHP
error_reporting (E_ALL ^E_NOTICE);
require_once("./inc/functions.inc.php");
require_once("./data/config.php");
//$PHP_SELF = "";
if($id != ""){
if($archive != ""){ $news_file = "./archives/$archive.news.arch"; }
else{ $news_file = "./news.txt"; }
$all_news = file("$news_file");
$found = FALSE;
foreach($all_news as $news_line){
$news_arr = explode("|", $news_line);
if($news_arr[0] == $id){ $found = TRUE; break;}
}
if($found == TRUE){
$title = $news_arr[2];
$date = date("j F Y h:i A", $news_arr[0]);
if($news_arr[4] != ""){
$news = replace_news("show", $news_arr[4]);
}else{
$news = replace_news("show", $news_arr[3]);
}
echo<<<PRINTABLE
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Printer Friendly Version</title>
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" onload="window.print()">
[b]$title[/b] @ <small>$date</small>
<hr>
$news
<hr>
<small>News powered by CuteNews - https://cutephp.com</small>
</BODY>
</HTML>
PRINTABLE;
}else{
echo"The news you what to print was not found.";
}
}else{ echo"No"; }
?>
In your templates where you want to make a link to the printer-friendly version insert this code:
print
Note:
Some versions of cutenews the config.php file is located in the inc folder... Change the code according to where your config.php file is located... Cheers