Post by wafflemeister » Tue Aug 25, 2015 1:42 am

Hi!

I would like to add a print button to the information page. If possible, I would like to add this on specific information pages only. If not, I guess a print button on all information pages would work also.

Thank you in advance.

Active Member

Posts

Joined
Fri Jun 21, 2013 11:10 pm

Post by ClosedCart » Tue Aug 25, 2015 2:41 am

Hey,

try going to code editing mode (by pressing the >< or whatever on the toolbar, or try pressing "source" if its there to go to code mode.

paste this:

Code: Select all

<html>
<head>
<title>PUT ANYTHING YOU WANT HERE</title>
</head>
<body>
<h1>Print Test</h1>
<input type="button" 
  onClick="window.print()" 
  value="Print This Page"/>
</body>
</html>
Put it at the top, bottom, or wherever you want. You can make it center or left or right too when you leave code mode and go to normal mode.

New member

Posts

Joined
Tue Jun 02, 2015 9:11 pm

Post by wafflemeister » Tue Aug 25, 2015 3:39 am

Thank you!
This works partially, as it will print the entire web page, with banners, ads, etc. I would need it to print only the section where the information is.

Active Member

Posts

Joined
Fri Jun 21, 2013 11:10 pm

Post by ClosedCart » Wed Aug 26, 2015 3:53 am

wafflemeister wrote:Thank you!
This works partially, as it will print the entire web page, with banners, ads, etc. I would need it to print only the section where the information is.
No problem, and sorry that I dont know how to do. Maybe someone else can chime in and help

New member

Posts

Joined
Tue Jun 02, 2015 9:11 pm

Post by straightlight » Wed Aug 26, 2015 4:22 am

I googled this subject a bit and the most easiest integration would be in your catalog/view/theme/<your_theme>/template/information/information.tpl file.

Find:

Code: Select all

<?php echo $footer; ?>
add above:

Code: Select all

<script language="text/javascript">
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>
From the previous post above, replace:

Code: Select all

onClick="window.print()"
with:

Code: Select all

onclick="printDiv('content')"
This should resolve the problem.

Source: http://stackoverflow.com/questions/4688 ... a-div-only

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by OSWorX » Wed Aug 26, 2015 5:59 pm

Or you could use this OCMod here:
Text2Print

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by wafflemeister » Thu Aug 27, 2015 5:44 pm

Thank you, this looks great but I unfortunately run 1.5.6.4
OSWorX wrote:Or you could use this OCMod here:
Text2Print

Active Member

Posts

Joined
Fri Jun 21, 2013 11:10 pm

Post by OSWorX » Thu Aug 27, 2015 6:07 pm

wafflemeister wrote:Thank you, this looks great but I unfortunately run 1.5.6.4
OSWorX wrote:Or you could use this OCMod here:
Text2Print
No problem to make also one for 1.5.x - as paid service.
Simply contact me and we can talk further.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Thu Aug 27, 2015 6:36 pm

wafflemeister wrote:Thank you, this looks great but I unfortunately run 1.5.6.4
OSWorX wrote:Or you could use this OCMod here:
Text2Print
The solution I posted is for 1.5 and 2.x releases and free release.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by IP_CAM » Fri Aug 28, 2015 12:58 am

I have been using this one for my OC v.1.5.6.x Test Shops, it's only two lines to place, to make it work, in a mono-language environment, and it only depends on, where one places the <div id="printview"> Frame-Start DIV , and the bottom End </DIV> to make it print, what one would like it to be.

http://forum.opencart.com/viewtopic.php ... 14#p498529

just to mention it!
Ernie

Sample Information Pages:
http://www.hitline.info/shop/index.php? ... ation_id=3
Example Information.tpl Source with Page Print Code included:

Code: Select all

<div id="printview">
  <script type="text/javascript">function printDiv(printview){var dd=document.getElementById(printview).innerHTML,ee=document.body.innerHTML;document.body.innerHTML=dd,window.print(),document.body.innerHTML=ee}</script>
<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?></h1>
  <?php echo $description; ?>
  <div class="buttons">
    <div class="right"><a href="javascript:printDiv('printview');" class="button" />Print Page</a> &nbsp;  <a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
  </div></div>
  <?php echo $content_bottom; ?></div>
<?php echo $footer; ?>
Header Initializer Part:

Code: Select all

<div id="printview">
  <script type="text/javascript">function printDiv(printview){var dd=document.getElementById(printview).innerHTML,ee=document.body.innerHTML;document.body.innerHTML=dd,window.print(),document.body.innerHTML=ee}</script>
Bottom Section Print Button Part:

Code: Select all

<a href="javascript:printDiv('printview');" class="button" />Print Page</a> &nbsp; &nbsp;
and after the following two </div>, place another:

Code: Select all

</div>
to close this Print <DIV>...</DIV> Section again.

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 278 guests