Print funktion...

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
Reo-X
Posts: 17
Joined: Sat 6. Dec 2003, 19:11
Location: Denmark
Contact:

Print funktion...

Post 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.
User avatar
Oliver Georgi
Site Admin
Posts: 9920
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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>';
}

?>
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
Oliver Georgi
Site Admin
Posts: 9920
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

The best place to put the {PHP:printwindow.php} replacement tag is at the end of the main block.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Reo-X
Posts: 17
Joined: Sat 6. Dec 2003, 19:11
Location: Denmark
Contact:

Post 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?
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post 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
http://www.studmed.dk Portal for doctors and medical students in Denmark
Reo-X
Posts: 17
Joined: Sat 6. Dec 2003, 19:11
Location: Denmark
Contact:

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9920
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Post Reply