Dabei wird zusätzlich ein frei erstellbarer Druckkopf angezeigt und mit ausgedruckt (z.B. Logo und Anschrift).
Dazu benötigt man:
1.) ein eigenes Layout (drucken)
Code: Alles auswählen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Meine Domain</title>
<link rel="stylesheet" media="screen" type="text/css" href="css/anzeige.css">
<link rel="stylesheet" media="print" type="text/css" href="css/drucken.css">
</head>
<body>
<div id="content">
CMS_CONTAINER[1]
CMS_CONTAINER[2]
</div>
</body>
</html>
Code: Alles auswählen
<?php
/***********************************************
* Article Include Output for Printing
*
* Author : Willi Man
* Copyright : Contenido - four for business
* Created : 18-12-2003
* Modified : 02-01-2004
* Modified : 05-08-2005, Andreas Lindner
* Modified : 20-11-2006, schlaucher
************************************************/
#Get current settings
//$cms_idcat = "CMS_VALUE[1]";
//$cms_idcatart = "CMS_VALUE[2]";
$bDebug = false;
if ($bDebug) echo "<pre> cat $cms_idcat catart $cms_idcatart</pre>";
if ((strlen($cms_idcat) > 0 AND $cms_idcat != '0') AND (strlen($cms_idcatart) > 0 AND $cms_idcatart != '0')) {
if (strlen($cms_idcatart) > 0 AND $cms_idcatart > 0) {
#Get idart from database
$sql = "SELECT idcat, idart
FROM ".$cfg["tab"]["cat_art"]."
WHERE idcatart='".$cms_idcatart."'";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
$db->next_record();
$cms_catid = $db->f("idcat");
$cms_artid = $db->f("idart");
$db->free();
}
if ($cms_idcatart == 0) {
$cms_catid = $cms_idcat;
$sql = "SELECT A.idart, B.lastmodified
FROM ".$cfg["tab"]["cat_art"]." AS A, ".$cfg["tab"]["art_lang"]." AS B
WHERE
A.idart = B.idart AND
B.online = 1 AND
A.idcat = '".$cms_idcat."'
ORDER BY B.lastmodified DESC";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
if ($db->next_record()) {
$cms_artid = $db->f("idart");
$lastmod = $db->f('lastmodified');
}
$db->free();
$sql = "SELECT idcatart
FROM ".$cfg["tab"]["cat_art"]."
WHERE
idart = '".$cms_artid."' AND
idcat = '".$cms_catid."' ";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
if ($db->next_record()) {
$cms_idcatart = $db->f("idcatart");
}
$db->free();
}
#Check if category is online or protected
$sql = "SELECT public, visible FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".$cms_catid."' AND idlang='".$lang."'";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
$db->next_record();
$public = $db->f("public");
$visible = $db->f("visible");
$db->free();
#Check if article is online
$sql = "SELECT online FROM ".$cfg["tab"]["art_lang"]." WHERE idart='".$cms_artid."' AND idlang='".$lang."'";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
$db->next_record();
$online = $db->f("online");
$db->free();
#If the article is online and the according category is not protected and visible, include the article
if ($public == 1 AND $visible == 1 AND $online == 1) {
#Check if code creation is necessary
$sql = "SELECT
createcode
FROM
".$cfg["tab"]["cat_art"]."
WHERE
idcat = '".$cms_catid."' AND
idart = '".$cms_artid."'";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
if ($db->next_record()) {
$createcode = $db->f("createcode");
} else {
$createcode = 1;
}
$db->free();
#Create code if necessary
if ($createcode == 1) {
cInclude('includes', 'functions.con.php');
cInclude('includes', 'functions.tpl.php');
cInclude('includes', 'functions.mod.php');
conGenerateCode($cms_catid, $cms_artid, $lang, $client);
}
#Get code from database and execute it
$sql = "SELECT code FROM ".$cfg["tab"]["code"]." WHERE idcatart = '".$cms_idcatart."' AND idlang = '".$lang."'";
if ($bDebug) {echo "<pre>";print_r($sql);echo "</pre>";}
$db->query($sql);
if ($db->next_record()) {
$code = stripslashes($db->f("code"));
$db->free();
ob_start();
eval("?>
".$code."
<?php
");
$code = ob_get_contents();
#Clean buffer
ob_end_clean();
$startpos = strpos($code, "<!--start:content-->");
$endpos = strpos($code, "<!--end:content-->");
$difflen = $endpos - $startpos;
$code = substr($code, $startpos, $difflen);
echo '<div id="print_button"><button class="button_print" onclick="self.print();">Drucken</button> <button class="button_print" onclick="self.close();">Schließen</button></div><hr>';
echo $code;
} else {
echo "<!-- ERROR in module Article Include<pre>no code created for article to include!<br>idcat $cms_catid, idart $cms_artid, idlang $lang, idclient $client</pre>-->";
}
}
}
?>
Code: Alles auswählen
#print_button
{
width:459px;
text-align:right;
left:0px;
top:0px;
}
#button{
margin-bottom:5px;}
.button_print
{
cursor: pointer;
border: #000000;
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
background-color: #ffffff;font-family:verdana,tahoma,arial, sans-serif;
font-size:10px;
font-weight: normal;
text-decoration:none;
}
CSS drucken
Code: Alles auswählen
#print_button
{
display:none;
}
#button
{
display:none;
}
3.) ein Template Druckvorschau
Name: Druckvorschau
Layout: drucken
Conatiner 1: Text (HTML)
Container 2: Artikel drucken
Nun erstellt man einen Druckvorschau Artikel auf Basis des Template Druckvorschau und definiert seinen Druckkopf. Der Artikel muss nicht über ein Menü ausrufbar sein. (Ich habe für solche Artikel einen Service Bereich)
Im Layout der Standardartikel, welche ausgedruckt werden sollen, müssen nun wie beim Artikel rechts auch, der Start und End Bereich definiert werden.
Beispiel:
Code: Alles auswählen
<div id="contentcenter">
<!-- Content -->
<!--start:content-->
CMS_CONTAINER[40]
CMS_CONTAINER[41]
CMS_CONTAINER[42]
CMS_CONTAINER[43]
<!--end:content-->
CMS_CONTAINER[44]
</div>
4.) Modul Druckvorschau
Input
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : Druckvorschau
* Version : 1.0
* Author : schlaucher
* Created : 19-11-2006
* Modified :
************************************************/
$MOD_DV_sel_idcat = "CMS_VALUE[1]";
$MOD_DV_sel_idcatart = "CMS_VALUE[2]";
echo '<table cellspacing="0" cellpadding="10" border="0"><tr valign="top">';
echo '<tr>
<td>'.mi18n("Kategorie der Druckvorschau wählen:").'</td>
<td>'.buildCategorySelect("CMS_VAR[1]", "CMS_VALUE[1]").'</td>
</tr>';
#Article selector
echo '<tr>
<td>'.mi18n("Artikel der Druckvorschau wählen").': </td>
<td style="padding:-5px">
<select name="CMS_VAR[2]" style="width:200px">
<option value="" selected>'.i18n("Bitte auswählen").'</option>';
if ($MOD_DV_sel_idcat != "0" && strlen($MOD_DV_sel_idcat) > 0)
{
$sql = "SELECT ARTLANG.title AS title, CATART.idcatart AS idcatart ";
$sql .= "FROM ".$cfg["tab"]["art_lang"]." AS ARTLANG,";
$sql .= " ".$cfg["tab"]["cat_art"]." AS CATART ";
$sql .= "WHERE CATART.idcat = '".$MOD_DV_sel_idcat."' ";
$sql .= "AND ARTLANG.idart = CATART.idart ";
$sql .= "AND ARTLANG.idlang = '".$lang."'";
$db->query($sql);
while ($db->next_record())
{
$MOD_DV_sel_catartid = $db->f('idcatart');
$MOD_DV_sel_title = $db->f('title');
if ($MOD_DV_sel_idcatart != $MOD_DV_sel_catartid)
{
echo '<option value="'.$MOD_DV_sel_catartid.'"> '.$MOD_DV_sel_title.'</option>';
} else {
echo '<option selected="selected" value="'.$MOD_DV_sel_catartid.'"> '.$MOD_DV_sel_title.'</option>';
}
}
}
echo '</select> <input type="image" src="images/submit.gif">
</td>
</tr>
</table>';
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Druckvorschau
* Version : 1.0
* Author : schlaucher
* Created : 19-11-2006
* Modified :
************************************************/
$MOD_DV_sel_idcatart = "CMS_VALUE[2]";
echo '
<div>
<a href="javascript:;" onclick="MM_openBrWindow(\'http://'.$SERVER_NAME.$SCRIPT_NAME.'?idcatart='.$MOD_DV_sel_idcatart.'&cms_idcatart='.$idcatart.'&cms_idcat='.$idcat.'\',\'\',\'resizable=yes, scrollbars=yes, width=700, height=750\')" style="font-size:10px;"><img src="upload/bilder/layout/drucker.jpg" style="margin-right:10px;margin-top:-4px;" align="absmiddle" width="20" height="13" alt="Druckvorschau" title="Druckvorschau" border="0"/>Druckvorschau</a></div>
<script type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>';
?>
Diese Modul muss in die Templates aller Artikel, welche ausgedruckt werden sollen. (Bei mir z.B. im Container 44)
fertig!
Gruß
schlaucher