Keyword

Printing an Item

  • Yiota
  • Yiota's Avatar
  • Visitor
14 years 5 months ago #81617 by Yiota
Replied by Yiota on topic Printing an Item
@Christoffer Müller :
Edit the k2.css by targeting all information you want to be able to print, like title, text (introtext, fulltext), image, etc. and start by referring to them by body.contentpane .itemTitle, body.contentpane .introText, etc.
All other information you don't want to be at this page, like rating, simply add body.contentpane .itemRatingBlock {display:none;}.


@Mats Arvendal : What do you mean by "change the order of the different parts"?

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #81618 by Mats Arvendal
Replied by Mats Arvendal on topic Printing an Item
Let's say I want to put the article parts itemTitle, author, introText etc in another order than the article displays on the webpage. I know how to customize the templates/views for the webpages, but how do I customize for the print function? Maybe I would like to add a script or a PHP code snippet. By what PHP files are the print page generated?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
14 years 5 months ago #81619 by Yiota
Replied by Yiota on topic Printing an Item
You can locate it inside your template override of k2, under "if($this->item->params->get('itemPrintButton')):" and on components/com_k2/models/item.php on line 67 there is the following statement.

//Print link
$item->printLink = urldecode(JRoute::_($link.'&tmpl=component&print=1'));

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #81620 by Mats Arvendal
Replied by Mats Arvendal on topic Printing an Item
Thanks for all help. Sorry if I not fully understand how to create and apply a special template for prints. Do I alter this code in any way to invoke a "print-only" template? I suppose the JRoute command picks up the template used for the specific item. I would for example be able to add an absolute path and perhaps a quick print script in the printed text wndow.

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
14 years 5 months ago #81621 by Yiota
Replied by Yiota on topic Printing an Item
Actually why go into so much trouble making a template for print by code and not simply use the CSS to create a totally different page? After all you do have an outer container to control all page. And with a simple display:none; to the elements you don't want to show and print you will spare a lot of time.

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #81622 by Mats Arvendal
Replied by Mats Arvendal on topic Printing an Item
Yeah, I may achieve most of my customizations via CSS, I have already stripped every item div that's not title, date, intro text and full text, but there are some more things I want to be able to do. Let's take an example, I want my printed page to contain this (from top to bottom):

1. A print button connected to a script to help people print without going to their browser's print tool
2. A simplfied website logo to identify the document (this may be solved via CSS)
3. An absolute path to the page (regardless of what the visitor has set in hers/his web browser print settings)
4. title
5. creation date
6. intro text
7. full text

In the template/view there's a different order, 5 comes above 4. So creation date and title will have to switch in the print. The actual website is serving both as an ordinary webstie and as an article archive where the output for the paper archive must look a certain way.

I hope you can make sense of this bewilderment.

Rgds

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
14 years 5 months ago #81623 by Yiota
Replied by Yiota on topic Printing an Item
You can modify your item.php page override, by controlling what you want to show and where, by making this simple if control: if(JRequest::getCmd('print')==1). You can see this statement where the print button is. I'm afraid that only with this "if" you can set the print page as you want.

Now the print page is loaded through the the component.php page inside your template folder. If you want to edit anything for the print page you should edit that.

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #81624 by Mats Arvendal
Replied by Mats Arvendal on topic Printing an Item
Great! This is what I was looking for.

Efharisto poli!

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #81625 by Mats Arvendal
Replied by Mats Arvendal on topic Printing an Item
Sorry, may I ask you to give me the paths to the files item.php and component.php? When I look in my html/k2/templates I find no component.php
Rgds

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
14 years 5 months ago #81626 by Yiota
Replied by Yiota on topic Printing an Item
Yes of course. The component.php is in templates/YOUR TEMPLATE/component.php and the item.php is in templates/YOUR TEMPLATE/html/com_k2/templates/default/item.php

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum