- Posts: 92
COMMUNITY FORUM
[SOLVED] Print View Override
- Mr_Anonymous
-
Topic Author
- Offline
- Premium Member
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
I personally add a new media query (@media print) in my template's stylesheet.
Please Log in or Create an account to join the conversation.
- Mr_Anonymous
-
Topic Author
- Offline
- Premium Member
- Posts: 92
Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Keep in mind that you might need a CSS solution as well, since Joomla!'s print button the browser's print button have a different result.
Please Log in or Create an account to join the conversation.
- Mr_Anonymous
-
Topic Author
- Offline
- Premium Member
- Posts: 92
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
Would you please let me know which file is correspondent for the print view?
I want to make a very neat print view but right now everything is included in it like an article.
Thanks,
Sohrab
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
How? can you provide an example please?
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
The file component.php acts as a wrapper for the K2 template files (item.php to be exact).
Examine this page for example: demo.getk2.org/item?tmpl=component&print=1 (although we don't use any specific print styling here).
You can event create an entirely different section for the print view in K2's item.php by having a big if/else statement there. Shouldn't be too difficult to see how to do that as it exists already in item.php, for example here: github.com/getk2/k2/blob/master/components/com_k2/templates/default/item.php#L15
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
I am studying them.
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
Would you please give me more direction like. A. do this.. B. do that...
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
<?php if(JRequest::getInt('print')==1): ?>
<!-- Print button at the top of the print page only -->
<a class="itemPrintThisPage" rel="nofollow" href="#" onclick="window.print();return false;">
<span><?php echo JText::_('K2_PRINT_THIS_PAGE'); ?></span>
</a>
<?php endif; ?>
the second line to call for the print js action.
the third for the text.
How can I force it to open a custom php tempelate?
what should write? please guide me. I am not that adept in php but understand it.
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
<?php if($this->item->params->get('itemPrintButton') && !JRequest::getInt('print')): ?>
<!-- Print Button -->
<li>
<a class="itemPrintLink" rel="nofollow" href="<?php echo $this->item->printLink; ?>" onclick="window.open(this.href,'printWindow','width=900,height=600,location=no,menubar=no,media=no,resizable=yes,scrollbars=yes'); return false;">
<span><?php echo JText::_('K2_PRINT'); ?></span>
</a>
</li>
<?php endif; ?>
I understand it but what should I write in the place of printLink to open my designed template or where is printLink to edit?
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
Ok I understood what you instructed. Very helpful.
Here I copy and paste what I did for my print layout so other like me won't get lost and can use this in no time:
<?php if(JRequest::getInt('print')==1): ?>
<!-- Print button at the top of the print page only -->
<a class="itemPrintThisPage" rel="nofollow" href="#" onclick="window.print();return false;">
<span><?php echo JText::_('K2_PRINT_THIS_PAGE'); ?></span>
</a>
<!-- 1 Item Title --> <h2 class="PrintTitle"><?php echo $this->item->title; ?></h2>
<!-- 2 Item Author --> <span class="PrintAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(empty($this->item->created_by_alias)): ?>
<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php endif; ?>
<!-- 3 Item Image -->
<span class="PrintImage">
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
</span>
<!-- 4 Item introtext -->
<div class="PrintIntroText">
<?php echo $this->item->introtext; ?>
</div>
<!-- 5 Item fulltext -->
<div class="PrintFullText">
<?php echo $this->item->fulltext; ?>
</div>
<?php else: ?>
<!-- End if moved to the very end of this page -->
<!-- Start K2 Item Layout -->
What you can not see here is that I moved the
<?php endif; ?>
Thanks
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
<a class="itemPrintThisPage" rel="nofollow" href="#" onclick="window.print();return false;">
<span><?php echo JText::_('K2_PRINT_THIS_PAGE'); ?></span>
</a>
So you can either remove it entirely or simply move it elsewhere (e.g. at the bottom of the document).
Please Log in or Create an account to join the conversation.
- Sori
-
- Offline
- Senior Member
- Posts: 60
I tried putting it everywhere. I still have it on the printed document.
On the original code that would go away on the printed document.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
You can keep the same class/markup as is or you can override k2.print.css by copying the file into /templates/YOUR_TEMPLATE/css/.
Please Log in or Create an account to join the conversation.