Own Print Layout - NOT using phpWCMS

If you have created additional (non official) documentation or tutorials or something like that please post this here
Post Reply
trip
Posts: 657
Joined: Tue 17. Feb 2004, 09:56
Location: Cape Town, South Africa
Contact:

Own Print Layout - NOT using phpWCMS

Post by trip »

Hi there
I have had this problem, so here is a solution....
A guide how to set this up is all in the doc below, you only need to add the special tags to your phpWCMS template and you are away...with your own print solution.

hope this helps those who need to get round this problem.
TriP

Code: Select all

<html>
<head>
  <title>Print version</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="own.css" rel="stylesheet" type="text/css">
</head>
<?php 

/*PHPrint - This file is printTemplate.php
Make any Page Printer Friendly! Copyright by MikeNew.Net, Notice must stay intact
************
Legal: MikeNew.Net is not responsible for any damages caused
by use of this script. (Not that it will, probably. Never has.)
This script will make your pages printer friendly. 
Optionally, it will strip images as well. (Instructions for that below)

/* Modification to the Script August 2002
1. Copyright by Mike in header
2. deleted extra http refer...
3. Changed filename to printTemplate.php
*/

// After installation, you can remove text from here down to the next: 8< ---->
// Back up/copy this file first.
/*
1. Save this script in the root of the site for simplicity.
2. Place <!-- startprint --> somewhere in your HTML page where you consider 
it to be the start of printer friendly content, and <!-- stopprint --> goes at the end
of that same content.

3. You place a link to phprint.php anywhere on the HTML page (preferably outside the printed content,
like this: <a href="/phprint.php">Print this page</a>
- or however you like, just as long as you link to this script. */

// If you've already tested, you can remove the text from here up to the other: 8< ---->

//Do you want to strip images from the printable output?
// If no, change to "no". Otherwise, images are stripped by default.

$stripImages = "no";
// That's it! No need to go below here. Upload it and test.

$startingpoint = "<!-- startprint -->";
$endingpoint = "<!-- stopprint -->";

$read = fopen($HTTP_REFERER, "rb");
$value = "";
while(!feof($read)){
$value .= fread($read, 4096); 
}
fclose($read);
$start= strpos($value, "$startingpoint"); 
$finish= strpos($value, "$endingpoint"); 
$length= $finish-$start;
$value=substr($value, $start, $length);

function i_denude($variable)
{
return(eregi_replace("<img src=[^>]*>", "", $variable));
}

function i_denudef($variable)
{
return(eregi_replace("<font[^>]*>", "", $variable));
}

$PHPrint = ("$value"); 

if ($stripImages == "yes") {
$PHPrint = i_denude("$PHPrint");
}

$PHPrint = i_denudef("$PHPrint");
$PHPrint = str_replace( "</font>", "", $PHPrint );

// Start of the Print echo on html
echo" own design here	";
echo " own design here";
echo "own design here";
echo $PHPrint; 
echo "own design here";
echo " own design here";
flush ();
?>
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

hey do you have demo?
http://www.studmed.dk Portal for doctors and medical students in Denmark
trip
Posts: 657
Joined: Tue 17. Feb 2004, 09:56
Location: Cape Town, South Africa
Contact:

Post by trip »

here is the url where I am using this script.
check the source code for the tags that I have used...

http://www.expats-in-bavaria.com/2/inde ... ommunities

Please check out the webpage of where the script comes from as there is an update, for the newer versions of php.

TriP
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Hi Trip

Post by jsw_nz »

Glad I bookmarked this page when you first posted it.
Works like a charm.

Comes in handy when working with pages that exist as part of project but exist strcictly speaking outside Wcms code.

Cheers,
John
spirelli
Posts: 996
Joined: Tue 27. Jul 2004, 13:37
Location: London

Post by spirelli »

Unfortunately this does not work when rewrite function is enabled.
http://www.phpwcms.de/forum/viewtopic.php?t=3759

Does someone have a different solution? I want to customize my printpage with a logo. But I use rewrite.
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

Hi,
I do not use the printlayoutpage anymore, because I think it is not really needed.

I go this way:

I put all my elements for screen and print inside my template.
all stuff which not shown on screen get a display:none; in frontend.css (by class or anything else)
the lastpart of my *.css looks like this:

Code: Select all

/* SCREEN STYLES */
body {
...
}

.noprint {display:none;}

/* PRINT_STYLE*/

@media print{
 .noprint {display:block;}
#leftBlock,#headerColumneLeft,#headerColumneMiddle,#headerColumneRight,#hcss_menu ul, #hcss_menu ul li a, #footermisc,
  #breadcrumb
  {display:none;
	background:transparent none;}
  
  body,#wrapper,#container,#footer{
  position: relative;
  width:auto;
  	overflow:visible !important;
    color:#000000;
  	margin:0;padding:0;
    }
  #rightBlock{
  width:auto;
  margin: 10px auto 2em auto;
  line-height:150%;
  }
  
  #header {
  height:auto;
  width:auto;
  }
  
  #headerLogoLink {
  margin:0 0 0 -5px;
  padding:0;
  }

}
take a look here and look at layout.css
http://tinyurl.com/36s9dh

hope that helps
marcus
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Post by juergen »

Hey marcus,

the PDF Part comes from filestorage or is it generated automaticly ?

Jürgen
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

DF6IH wrote:the PDF Part comes from filestorage or is it generated automaticly ?
it's pure magic ;-)

no - this are parts from a pdf generation hack here in forum (using html2fpdf class) tweaked and bended to my needs (incl. template) if I finish the site and clear up the code I will post this RT, but there are some bugs inside...
But as I said - it based mainly on the found stuff in forum - the only thing I did is PDF templatesetup (similar to printpagelayout - nothing big) and some FPDF Magic like include Meta Information into the PDF and figuring out, that Layout is very very basic - and make some problems if there are a lot of nested elements.
Post Reply