Page 1 of 1

Print funktion...

Posted: Sat 27. Dec 2003, 21:42
by Reo-X
I just found out that when pressing the "print" link or image on the content pages it only opens the same page with different css.

how can i make the new page that it opens also print automaticly, or at least ask if it should print it?

the file content.func.inc.php contains this string:

Code: Select all

// print layout button replacement
if( ! ( strpos($content["all"],'[PRINT]')===false ) ) {
	$content["all"] = str_replace('[PRINT]', '<a href="index.php?id='.$aktion[0].','.$aktion[1].',1,'.$aktion[3].','.$aktion[4].','.$aktion[5].'" target="_blank">', $content["all"]);
	$content["all"] = str_replace('[/PRINT]', '</a>', $content["all"]);
}
i realise that this string is the one the [print] tags are replaced with, however i don't know any code that is added to the <a href=""> tags, so the only other method of doing this is to do something with the css, but again here i don't know any code that does that, so if anyone here can help me, please do so.

Posted: Wed 31. Dec 2003, 08:23
by Oliver Georgi
create a new php script that you can include in your template anywhere.

Inside your script check if $aktion[2] == 1 if so make a PHP echo that returns the JavaScript print code. This works:

Code: Select all

<?php
// returns JavaScript Print script
if($GLOBALS['aktion'][2] !=0) {
	echo '<script language="JavaScript" type="text/javascript">';
	echo "\n<!--\n";
	echo 'window.print();';
	echo "\n//-->\n";
	echo '</script>';
}

?>

Posted: Wed 31. Dec 2003, 08:24
by Oliver Georgi
The best place to put the {PHP:printwindow.php} replacement tag is at the end of the main block.

Posted: Wed 31. Dec 2003, 12:14
by Reo-X
sorry, i have no idea what php concerns, so before i do that stuff, will it then make the page that appears when the print link is clicked print automaticly? or all the pages?

Posted: Wed 31. Dec 2003, 14:45
by frold
just the page, and you have to accept the print...it give you the same link as normal when use the print function, and then it open your print window (the same you get when pressin ctrl+p in a danish IE 6.0)

- hope you understand

Posted: Wed 31. Dec 2003, 16:02
by Reo-X
thanks, just what i wanted to know :D

EDIT:

hmmm, added the code to the content.func.inc.php file and the action is set to 1.

then added the {PHP:printwindow.php} at the bottom of the main template

now when i access the phpwcms i only get a blank page :/

EDIT:

When i changed the action to 1 from 0 before, that was the reason i got a blank page, no idea why, but now its set to 0 again, the php you posted above is in a seperate file (must've overlooked that line) now it works

Posted: Wed 31. Dec 2003, 17:46
by Oliver Georgi
That's write - you have to create a new PHP file and put in the above code. It is an external PHP script. ;-)

Oliver