Print template for spicific page.

Please post the URLs to pages, where you've made a CMSimple template available for download

Moderator: mikey

Post Reply
Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Print template for spicific page.

Post by Tata » 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.).
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?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Print template for spicific page.

Post by cmb » Fri Jun 29, 2018 9:51 am

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)
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Print template for spicific page.

Post by Tata » Fri Jun 29, 2018 10:09 am

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 .= '';#
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Print template for spicific page.

Post by cmb » Fri Jun 29, 2018 10:48 am

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);#
Last edited by cmb on Fri Jun 29, 2018 12:11 pm, edited 1 time in total.
Reason: Fixed code snippet
Christoph M. Becker – Plugins for CMSimple_XH

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Print template for spicific page.

Post by lck » 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.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Print template for spicific page.

Post by Tata » 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
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Print template for spicific page.

Post by cmb » Fri Jun 29, 2018 12:14 pm

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.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Print template for spicific page.

Post by Tata » 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).
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Print template for spicific page.

Post by cmb » Fri Jun 29, 2018 2:37 pm

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}
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Print template for spicific page.

Post by Tata » Fri Jun 29, 2018 3:48 pm

Super" It works this way wonderful.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply