Forums / Setup & design / Printable page

Printable page

Author Message

Bill Rust

Monday 19 February 2007 9:38:32 am

I'm struggling with getting a functioning printable page for my article class. I've stuck the print_pagelayout.tpl as an override and added the url link in my article class


<a href={concat('/layout/set/print/content/view/full',$node.node_id)|ezurl}>{"Printable page"|i18n("design/base")}</a>

However, after a cache clear, I get the new view but not any of the text. I am also able to modify the print_pagelayout.tpl to include a site banner, but still without any of the article text.

I'm also having difficulty getting either of the links - recommended in the documentation - working so I'm not able to link back to the article. This suggests that I'm best off using a popup printable page, but I'm not sure how I would get that to work either.

Could anyone give me any pointers?

Softriva .com

Monday 19 February 2007 10:44:57 am

the $node is cached I do the following to overcome the problem

{def $my_node = fetch( content, node, hash( node_id, $module_result.node_id) )}

the above pertains to my case. You can write your own fetch code.

then you can use $my_node instead of $node.

I hope this help.

Bill Rust

Thursday 22 March 2007 6:58:41 am

Ah yes, so the print view isn't cached. Being a bit of a newbie to eZ coding and using the above code to define $my_node, how quite do I then get it to give me a printable view of the article?

Am I to use the

{attribute_view_gui attribute

? Do I need to use

{attribute_view_gui attribute

?

Any tips are most appreciated.

Thanks

Jon Staines

Friday 23 March 2007 3:29:34 am

I tried the link that you entered in the parent post and had the same problem that you had, no article content on the printing page. Turning on debug showed that it was looking for a template called full83.tpl which of course doesn't exist (I was looking at node 83). You are missing a slash in your link after 'full', it should be:

<a href={concat('/layout/set/print/content/view/full/',$node.node_id)|ezurl}>{"Printable page"|i18n("design/base")}</a>

You can then always make an override to any of the print templates to display them differently.

Bill Rust

Tuesday 27 March 2007 6:05:07 am

Thanks for helping Jon, I changed the link in the article.tpl to the one you suggested and it seems to work a bit better. The new window has the link
http://example.com/index.php/news/layout/set/print/content/view/full/14714

That's good, but I'm still not getting any of the article content. My basic eZ code means I'm a little unsure of what code I now need to use to extract the code in the print_pagelayout template.

One thing though, I have the debug turned on and it does appear to be using the right template - the print_pagelayout.tpl. That's pretty obvious anyway because I have some code in there to pull out the website's logo and that, I'm glad to see, does appear.

Jon Staines

Tuesday 27 March 2007 6:48:36 am

The important part of the print template is

{include uri="design:page_mainarea.tpl"}

which by default will call:

{$module_result.content}

If you have debug on then it should show the page_mainarea.tpl being loaded.

Bill Rust

Sunday 01 April 2007 7:15:47 am

Yes that works great, I hadn't realised how the page_mainarea.tpl really worked.

The only problem I now have is that I don't want the article content on the printing page to be exactly that of the article page. For example I have a link to view a printable page on the printing page, which looks pretty stupid. Is there anyway to exclude such things?

Also, when using a popup page am I able to restrict the dimensions of the new window?

Many thanks, I'm learning!

Jon Staines

Monday 02 April 2007 1:46:29 am

For small changes like removing the link you are probably better off using CSS to remove it. So you could add this to the print_pagelayout.tpl file:

<link rel="stylesheet" type="text/css" href={"stylesheets/print.css"|ezdesign} />

Change the link in the article template to have a CSS identifier (id or class):

<a class="print" href={concat('/layout/set/print/content/view/full/',$node.node_id)|ezurl}>{"Printable page"|i18n("design/base")}</a>

Then add something to the print.css to hide it:

a.print
{
 display: none;
}

I'm not sure what the correct method would be for larger changes to the layout, but you could probably use one of the $module_result properties in the article template to work out when a page is being printed.

As for pop ups, how are you making it pop up? HTML or Javascript?

Xavier Dutoit

Monday 02 April 2007 5:09:16 am

Hi,

add on your pagelayout.tpl

<link rel="stylesheet"
type="text/css"
media="print" href={"stylesheets/print.css"|ezdesign} />

and create the stylesheet your need for print (display none the menu and whatever...)

More about it:
http://alistapart.com/articles/goingtoprint/

X+

http://www.sydesy.com

Bill Rust

Monday 02 April 2007 9:48:47 am

Brilliant, you've cracked it for me Jon, I'm pretty much now able to do everything I need.

Regarding the popup page, I'm simply using the target="new" bit of code in my article template. Am I able to use html to define the dimensions of the new window?

Thanks also Xavier, I had realised a few days ago that I could have taken your approach to accomplish everything I wanted, but I had already set off trying to do it another way. And it's that way I'll finish it! Fingers crossed! Thanks anyway for the advice.

Jon Staines

Tuesday 03 April 2007 1:03:50 am

Glad the printable page part is working. I'm not sure there is a way to resize the new window in html. You would need to have an onload or similar bit of javascript on the pop up window to do the resizing. Alternatively, you could change the launching link to use javascript to open the window with dimensions set at that point.

Six to one, half a dozen to the other.

Bill Rust

Sunday 08 April 2007 6:36:19 am

I've never heard of being able to resize popup windows in html so I'll try my hand at some javascript. I am presuming that it is perfectly fine to use javascript and there are various bits of javascript I can "borrow" from around the net that would do the job for me. Would I be employing the javascript in the article.tpl or the printable_page.tpl?

Jon Staines

Tuesday 10 April 2007 1:29:50 am

I'd put it in the article.tpl, remember to make it accessible: http://alistapart.com/articles/popuplinks

Javascript works in templates but remember to use:

{ldelim} and {rdelim} for { and }

Or put the javascript in an external file and include it with the usual:

<script type="text/javascript" src="filename.js"></script>

Hope this helps.

Bill Rust

Tuesday 10 April 2007 7:35:22 am

It helps enormously John, thanks again!

I'm going to put the javascript in a seperate external file and link to it. Is there a right place to put my javascript file? Would it go in the templates/overrides directory?

Assuming eZ finds my java file I would make the file popup by employing this bit of code

<script type="text/javascript src="popup.js" >
<a class="print" href={concat('/layout/set/print/content/view/full/',$node.node_id)|ezurl} target="new" onclick"link="link_popup(this); return false">{'application/pdf'|mimetype_icon( small, "Download PDF"|i18n( "design/base" ) )} {"Printable page"|i18n("design/base")}</a></script>

Also, one final thing (!) I'm not quite sure how the little mimetype_icon works. Above you can see that I've used the pdf icon to go with the link, but it's not clear to me where the icon is stored or how I can add another one, for example, a envelope for tip a friend, or a printer symbol for a printable page. Do you have any tips?

Jon Staines

Tuesday 10 April 2007 8:02:04 am

You should find a folder called javascript on the same level as the templates folder and using the ezdesign template feature to find it. ie:

<script type="text/javascript" src={"javascript/popup.js"|ezdesign}></script>

Your bit of code will need the link outside of the script block. For ease of testing I suggest playing with it in a bare html page (outside of ez publish) until it works the way you want. And then adding it to a template.

The pdf image is stored in share/icons/crystal/16x16/mimetypes/

For your own images however, make an image and add it to the images folder of your site design (same level as templates, stylesheets and javascript folders) and then have some code such as:

<img src={"envelope.png"|ezimage} width="16" height="16" alt="Email a friend" title="Email a friend" />

This way you let the ezimage feature go and find your new icon.

Bill Rust

Tuesday 17 April 2007 8:09:22 am

Hmm, I'm using eZ 3.4.4 and I don't think that having a javascript folder on the same level as the templates folder exists. I guess I'll have to upgrade to a new eZ before I'm able to use Java then.

Thanks for locating the PDF images, that's another thing I can tick off my list courtesy of your help Jon!

Jon Staines

Tuesday 17 April 2007 8:29:43 am

It's probably worth updating to at least the latest 3.6 so long as your system is able to.

I've not used 3.4 (I started with 3.6) so I'm not sure what to do with Javascript in it. You will be able to use it, I'm just not sure how. Try searching within your eZ Publish directory for other .js files. If you find some in a folder such as design/standard/javascript/, then it is most likely the same format as 3.6+ and you can make a javascript folder within your site design folder (or you could even put your javascript file inthe standard/javascript one).

In the end you could always put all the javascript directly into the template.

Bill Rust

Thursday 26 April 2007 7:35:01 am

I've been putting off upgrading for a few months now, but I think it's finally time to go up to 3.6. Hopefully my site should handle it.

One FINAL question - though perhaps I should have opened up a new thread for this - is, I want to change the name of tip a friend to email a friend. I've changed all instances of it in the article.tpl, emailafriend.tpl and emailafriendmail.tpl (formerly tipafriend.tpl and tipafriendmail.tpl) but I'm now denied access. Is there a setting for tipafriend that I need to change to emailafriend?

Many, many thanks Jon

Jon Staines

Thursday 26 April 2007 8:04:47 am

The easiest way would be to just change both the text in the link and the h1 element at the top of the tipafriend.tpl files to say "Email a friend". The URL would still be content/tipafriend/ but the text on the page would now say email. Changing the site to accept content/emailafriend/ is harder.

Horst Lindlbauer

Wednesday 18 June 2008 3:26:41 am

The css solution does not work for me. I need special print templates.
Any solutions?

---------------------------------------
http://www.lbm-services.de