Buy Now
Sign in

Add print button - CC5

FenFire , August 15 2014
Answered
Featured
F
FenFire
Hello,
I read this topic about adding a print button. Unfortunately it doesn't work.
But first, for those who want to use it with CC5, there are two important changes in the link parameters:
1. option=com_chronoconnectivity5
2. ccname=<your connection> [instead of connectionname]

So, this is my code in the header:
<script type="text/javascript">
function printPartOfPage(elementId)
{
var printContent = document.getElementById(elementId);
var windowUrl = 'about:NAME';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'left=1,top=1,width=400,height=400');

printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
</script>
<a style="float:right;" href="index.php?option=com_chronoconnectivity5&ccname=Auto_leihen&print=1&layout=default&page=" title="Print" onclick="JavaScript:printPartOfPage('PRINTAREA');" rel="nofollow"><img src="templates/kwh2/images/system/printButton.png" alt="Print" /> Drucken</a>

<div id="PRINTAREA">


and of course there's a </div> in the footer.
Everything looks fine in frontend, but nothing happens if I try to print. What did I do wrong?
calculus00
Hello FenFire,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I add a Print button to my form?
P.S: I'm just an automated service
I'm an automated service, my answers may help, but they may not be accurate.
F
FenFire
That's an explanation for CF4. I tried to use it in CC5 - and failed
admin
So the code in your first post doesn't work at all ?
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
F
FenFire
Well, there is a link/button for printing, and it links to the supposed adress (...?ccname=Auto_leihen&print=1&layout=default&page=), but nothing like printing happens. As I understand, a new windows should open - this doesn't happen. It's like this with both solutions.
F
FenFire
I finally managed to do this also. I think there are some errors in the FAQ Calculus "mentioned", or at least some things that do not work in CC5.
Here's the code:
<?php
$doc =& JFactory::getDocument();
$script = "
function printPage()
{
var html, printWin;
css = '<style type=\"text/css\">'+#css-styles#+'</style>';
html = '<html><head>'+css+'</head>'+print_div.innerHTML+'</html>';

printWin = window.open('', '', 'left=100, top=100, width=600, height=400, toolbar=0, scrollbars=0, status=0' );
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
var id;
jQuery(document).ready(function($){ //window.addEvent doesn't work for me
id = 'print_div';
$('print_button').setStyle('visibility', 'visible');
$('print_button').addEvent('click', printPage()); //impossible to get this working without () after printPage()
});
";
$doc->addScriptDeclaration($script);
?>

<div id="drucken" style="float:right;;margin-bottom:-40px;"><input type="image" src="templates/kwh2/images/system/printButton.png" id="print_button" title="drucken" onclick="printPage()"/> <a href="#" onclick="printPage()">Drucken</a></div>

<div id="print_div">
<h2 class="item-title">#title#</h2>


<div style="float:left;width:200px;"><strong>Suchen nach: </strong> <input style="height:25px;" type="text" name="srch" /></div><br />
<br />

<div style="float:right;margin-top:-42px;">_PAGINATOR_LIST_
_PAGINATOR_NAV_</div>
<div style="text-align:right;margin-top:0px">_PAGINATOR_INFO_</div>


and of course there's a </div> in the footer area.

Regards,
Christian
H
homeopat
Hi FenFire,

I did try your code and didnt work. I put him to the header section (I dont use custom code, table display type). of course I put </div> to the footer section.
where can be a problem?
thx
F
FenFire
Hi,
have you seen that line with: #css-styles#. Maybe there you have to type your css-styles. I replaced mine with a placeholder, as they wouldn't be useful for you. If you do not want styling attributes, try to delete that line. Maybe it works then. I'm not good at that.
Chees,
Christian