Page 1 of 1

Print template for spicific page.

Posted: Fri Jun 29, 2018 5:05 am
by Tata
I administer a page of a restaurant. There is adjusted a script publishing a daily menu every day at a specific time. The menu looks like this and is called into the newsbox on the right at the specified time.
I would like to have a "print button" on the page thet would print the very page with some unique styling (e.g. banner, logo, footer, blank background, another font sizes etc.).
The direct link .../?!!!_denne_menu&print doesn't work as expected (400). It must be written as .../?%21%21%21_denne_menu&print. Evidently some setting is wrong. But how to set the styling for "print" only for this only page?

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 9:51 am
by cmb
Tata wrote:
Fri Jun 29, 2018 5:05 am
The direct link .../?!!!_denne_menu&print doesn't work as expected (400). It must be written as .../?%21%21%21_denne_menu&print. Evidently some setting is wrong.
That's expected behavior, since the exclamation mark (!) is a reserved character according to RFC 3986, and as such must be escaped. You can use urichar_org/new to remove all exclamation from the URL.
Tata wrote:
Fri Jun 29, 2018 5:05 am
I administer a page of a restaurant. There is adjusted a script publishing a daily menu every day at a specific time. The menu looks like this and is called into the newsbox on the right at the specified time.
I would like to have a "print button" on the page thet would print the very page with some unique styling (e.g. banner, logo, footer, blank background, another font sizes etc.).
It's a bit tricky to style the printview of individual pages. Maybe the simplest solution is to link a separate stylesheet on the newspage, for instance:

Code: Select all

#CMSimple $hjs .= '<link rel="stylesheet" href=" . $pth['folder']['template'] . 'mystyle.css">';#
(not sure if TinyMCE likes that, though)

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 10:09 am
by Tata
Thanks, Chris!
cmb wrote:
Fri Jun 29, 2018 9:51 am
That's expected behavior, since the exclamation mark (!) is a reserved character according to RFC 3986, and as such must be escaped. You can use urichar_org/new to remove all exclamation from the URL.
I think that renaming the page would be much simpler and safer.
cmb wrote: It's a bit tricky to style the printview of individual pages. Maybe the simplest solution is to link a separate stylesheet on the newspage, for instance:

Code: Select all

#CMSimple $hjs .= '<link rel="stylesheet" href=" . $pth['folder']['template'] . 'mystyle.css">';#
(not sure if TinyMCE likes that, though)
There is a problem with the editor though. Inserting the code after the page title there remains after saving only

Code: Select all

#CMSimple $hjs .= '';#

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 10:48 am
by cmb
Tata wrote:
Fri Jun 29, 2018 10:09 am
There is a problem with the editor though. Inserting the code after the page title there remains after saving only

Code: Select all

#CMSimple $hjs .= '';#
Please try:

Code: Select all

#CMSimple $hjs .= chr(60) . 'link rel="stylesheet" href="' . $pth['folder']['template'] . 'mystyle.css"' . chr(62);#

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 11:24 am
by lck
Tata wrote:
Fri Jun 29, 2018 5:05 am
But how to set the styling for "print" only for this only page?
Auch eine Möglichkeit, einzufügen in template.htm.

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 11:24 am
by Tata
XHdebug:
Parse error: syntax error, unexpected 'link' (T_STRING) in /Users/msereday/webpages/ukastelana-aktual/cmsimple/functions.php(183) : eval()'d code on line 1

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 12:14 pm
by cmb
lck wrote:
Fri Jun 29, 2018 11:24 am
Tata wrote:
Fri Jun 29, 2018 5:05 am
But how to set the styling for "print" only for this only page?
Auch eine Möglichkeit, einzufügen in template.htm.
That wouldn't work for the print view, though, since the print view doesn't use template.htm (but an own minimal built-in template instead).
Tata wrote:
Fri Jun 29, 2018 11:24 am
XHdebug:
Parse error: syntax error, unexpected 'link' (T_STRING) in /Users/msereday/webpages/ukastelana-aktual/cmsimple/functions.php(183) : eval()'d code on line 1
Oops! I've fixed the code snippet above now.

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 2:32 pm
by Tata
Half way good.
The stylesheet "mystyle.css" is accepted and works fine. But for the "daily menu" page it works all the time (&normal or &print).

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 2:37 pm
by cmb
Tata wrote:
Fri Jun 29, 2018 2:32 pm
Half way good.
The stylesheet "mystyle.css" is accepted and works fine. But for the "daily menu" page it works all the time (&normal or &print).
The print view sets class print for the body element, which you can use to apply the styles only to the print view, e.g.

Code: Select all

body.print p {font-size: 2em}
body.print a {text-decoration: none}

Re: Print template for spicific page.

Posted: Fri Jun 29, 2018 3:48 pm
by Tata
Super" It works this way wonderful.