print function does not include the print_layout.css

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
silver
Posts: 16
Joined: Sun 13. Aug 2006, 04:52
Location: Cologne, Germany

print function does not include the print_layout.css

Post by silver »

Hi everybody,

I've just updated to the 1.2.8 and everything works fine for me.

Now I have a litte trouble with the built-in print function:

First I had to comment out line 62 in switchFontSize.php that has caused an php error when rendering the print page.

Now I found, that the print_layout.css gets not included into the generatet print page and therfore I cannot customize the print layout.

Does Anyone have an idea?
Thanks in advace.

silver
phpwcms 1.2.8 (20060825) · rewrite on · no mods

PHP Version 4.4.2 (CGI)
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Re: print function does not include the print_layout.css

Post by DeXXus »

silver wrote:First I had to comment out line 62 in switchFontSize.php that has caused an php error when rendering the print page.
How about listing the "actual" error?
silver
Posts: 16
Joined: Sun 13. Aug 2006, 04:52
Location: Cologne, Germany

Post by silver »

Hi DeXXus,

the error when NOT commenting out line 62 was:

Code: Select all

Fatal error: [] operator not supported for strings in /neu/phpwcms_template/inc_script/frontend_render/switchFontSize.php on line 62
After I Had commented it out, the print layout renders, but the print_layout.css is not included. (When I look in the source code of the rendered print layout in my browser, I see, that there is no CSS File included.)

BR

silver
phpwcms 1.2.8 (20060825) · rewrite on · no mods

PHP Version 4.4.2 (CGI)
kaju74
Posts: 68
Joined: Fri 5. Mar 2004, 11:24

Post by kaju74 »

Just replace

Code: Select all

$block['css'][]  = 'fontSize/'.$newFontSizeCSS;
with

Code: Select all

if(is_string($block['css']))
  $block['css'] = array($block['css']);

$block['css'][]  = 'fontSize/'.$newFontSizeCSS;
and everything seems to work :D
silver
Posts: 16
Joined: Sun 13. Aug 2006, 04:52
Location: Cologne, Germany

Post by silver »

Hi kaju74,

Thanks a lot!

That works! :D

Have a good day

silver
phpwcms 1.2.8 (20060825) · rewrite on · no mods

PHP Version 4.4.2 (CGI)
User avatar
Oliver Georgi
Site Admin
Posts: 9917
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

It's fixed. In content.func.inc.php around line 360 change it to this

Code: Select all

//if print layout should be shown
$block["css"][]	= 'print_layout.css'; //sets css to standard printing layout
Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
vlado
Posts: 5
Joined: Mon 9. Jul 2007, 15:02

print_leayout.css not included in v.1.3.3 ?

Post by vlado »

Is this still missing in v1.3.3 ???
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Re: print_leayout.css not included in v.1.3.3 ?

Post by DeXXus »

vlado wrote:Is this still missing in v1.3.3 ???
The whole "method" was changed right AFTER this thread:
"changelog.txt"
2006-08-17
[FIX] Print CSS file is added as array element now - the original has set $block['css'] back to string which might result in an error.
vlado
Posts: 5
Joined: Mon 9. Jul 2007, 15:02

Post by vlado »

So how does it work now? It still does not include print_layout.css when I use [PRINT] tag in 1.3.3
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

vlado wrote:So how does it work now? It still does not include print_layout.css when I use [PRINT] tag in 1.3.3
OK, it ~looks~ like this thread answers your question:

http://www.phpwcms.de/forum/viewtopic.p ... int+layout
Wrapping your [PRINT][/PRINT] tags with the <!--NO_PRINT_START//--> and <!--NO_PRINT_END//--> delimiters

BUT that seems to be BECAUSE the coding to apply "print_lauout.css is written like this in "content.func.inc.php":

Code: Select all

// check if print mode - then try to replace "no-print" sections from source
if(strpos($content['all'], 'NO_PRINT')) {
	if($aktion[2] == 1) {

		$content['all'] = replace_tmpl_section('NO_PRINT', $content['all']);
		$block['css']	= array('print_layout.css');

	} else {

		$content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']);

	}
}
It seems to be ONLY "applied" WHEN WRAPPED (using that program logic).
Try changing this portion:

Code: Select all

	} else {

		$content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']);
To this:

Code: Select all

	} else {

		$content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']);
		$block['css']	= array('print_layout.css');
vlado
Posts: 5
Joined: Mon 9. Jul 2007, 15:02

Post by vlado »

Ok, now I see. So I have two options:

1. include in my print.tmpl <!--NO_PRINT_START//--><!--NO_PRINT_END//-->
this is an only way how content.func.inc.php replaces all other xxxx.css with only one - print_layout.css in page without changing php code.

2. change code in content.func.inc.php
I think more logical than Dexxus way is to add a line under this comment line as Oliver suggested but I want to replace frontend.css not just add print_layout.css:

Code: Select all

//if print layout should be shown 
$block["css"][0]   = 'print_layout.css'; 
In this case you don't need to worry about NO_PRINT tags at all and it will replace only first css (usually frontend.css) by print_layout.css.

Am I correct?
Post Reply