Klar!
Es war übrigens nichts beim Update von 4.3.x auf 4.4 anzupassen. Es lief einfach! (hätte ich mit meinen Fähigkeiten auch nicht modifizieren können ...)
Code: Alles auswählen
NAME (bei mir): Artikelliste mit Headline, Subheadline und Thumbnails
BESCHREIBUNG: Benötigt einen Ordner "thumbnails" im Uploadordner.
Benötigt den document_root für $filedir
Die Größe der Thumnails kann geändert werden, wenn die Thumbnails aus dem Ordner Thumbnail gelöscht werden.
(Anmerkung: Habe ich entsprechend meinem Server angepaßt. Suche mal im Output nach "$filedir"!)
INPUT:
/**
* Artikelliste
*
* Erstellt eine Liste mit allen Artikel
* optional mit Startartikel, Überschrift der Liste,
* Headline, Subheadline, Thumbnails,
* Größe der Thumbnails.
*
* INPUT
*
* Author Jan Lengowski geändert/erweitert Dirk Uptmoor 9/03
* Copyright four for business AG
*/
// selected category
$selected = "CMS_VALUE[0]";
//funktion für die checkboxen
function d_checked($which) {
if ($which != "") {
return "checked";
}
} // end function
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
<tr bgcolor=\"#DFE4E4\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked("CMS_VALUE[9]")." name=\"CMS_VAR[9]\"></td>
<td width=\"120\">Ausgabe mit Startartikel</td>
<td></td>
<td>Kategorie wählen:<br>
<select name=\"CMS_VAR[0]\">";
if($selected!="0" && $selected!=""){
echo"<option value=\"0\">--- kein ---</option>";
}else{
echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
}
// fetch all categorys
$query = "SELECT A.idcat, A.level, C.name FROM ".$cfg["tab"]["cat_tree"]." AS A, ".
$cfg["tab"]["cat"]." AS B, ".$cfg["tab"]["cat_lang"]." AS C WHERE A.idcat=B.idcat ".
"AND B.idcat=C.idcat AND C.idlang='$lang' AND B.idclient='$client' ".
"AND C.visible=1 ORDER BY A.idtree";
// execute query
$db->query($query);
// loop result and build the options
while ($db->next_record()) {
// indent spacer
$spaces = "|";
// how many levels
$levels = $db->f("level");
for ($i = 0; $i < $levels; $i ++) {
// add 2 spaces for every level
$spaces = $spaces . "--";
} // end for
$spaces .= ">";
if ($selected == $db->f("idcat")) {
// selected category
echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";
} else {
// category
echo "<option value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";
} // end if
} // end while
echo "</select>";
echo "</td>
</tr>
<tr valign=\"top\">
<td></td>
<td></td>
<td width=\"120\"></td>
<td></td>
<td>Überschrift: (wenn leer, keine Ausgabe)<br>
<input type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#DFE4E4\" valign=\"top\">
<td></td>
<td> <input type=\"checkbox\" value=\"on\" ".d_checked("CMS_VALUE[4]")." name=\"CMS_VAR[4]\"> </td>
<td width=\"120\">Ausgabe der Artikel-Headline</td>
<td></td>
<td>Angezeigte Länge der Artikel-Headline in Zeichen:<br>
<input type=\"text\" name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\" size=\"24\"></td>
</tr>
<tr valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked("CMS_VALUE[5]")." name=\"CMS_VAR[5]\"></td>
<td width=\"120\">Ausgabe der Artikel-Subheadline:</td>
<td></td>
<td>Angezeigte Länge der Artikel-Subheadline in Zeichen:<br>
<input type=\"text\" name=\"CMS_VAR[6]\" value=\"CMS_VALUE[6]\" size=\"24\"></td>
</tr>
<tr bgcolor=\"#DFE4E4\" valign=\"top\">
<td></td>
<td><input type=\"checkbox\" value=\"on\" ".d_checked("CMS_VALUE[7]")." name=\"CMS_VAR[7]\" ></td>
<td width=\"120\">Ausgabe der Thumbnails:</td>
<td></td>
<td>Breite der Thumbnails: (Empfehlung 80)<br>
<input type=\"text\" name=\"CMS_VAR[8]\" value=\"CMS_VALUE[8]\" size=\"4\"></td>
</tr>
<tr valign=\"top\">
<td></td>
<td></td>
<td width=\"120\"></td>
<td></td>
<td></td>
</tr>
</table>
"; //Ende
OUTPUT:
<?
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Erweiterte Artikel liste
*
* Liste von Artikeln mit mehreren Daten basierend
* auf 4fb referenz modul
* Gibt die Subheadline eines Artikel mit aus (anstatt des Summery) upt.
*
* Author : Evert Smit / Dirk Uptmoor
* Copyright : 4fB
* Created : 13-07-2003
* Modified : 16-08-2002 /20-9-2003 upt
************************************************/
$startarton = "AND CATART.is_start = '0' AND";
//soll der startartikel mit ausgegeben werden?.
$print_startartikel = "CMS_VALUE[9]";
if($print_startartikel !=""){
$startarton = "AND";
}
//die Überschrift wird ausgegeben wenn sie nicht leer ist.
$print_mainheadline = "CMS_VALUE[2]";
//soll headline ausgegeben werden?
$print_headline = "CMS_VALUE[4]";
//soll subheadline ausgegeben werden?
$print_subheadline = "CMS_VALUE[5]";
//soll ein thumnail ausgegeben werden?
$print_thumbnail = "CMS_VALUE[7]";
//thumbnail breite
$thumbnail_width = "CMS_VALUE[8]";
//wenn thumbnails = 0
$imagetag = "";
// second db class instance
$db2 = new DB_Contenido;
// selected category
$selcat = "CMS_VALUE[0]";
if($selcat!="0" && $selcat!=""){
// select all articles in category widthout start article
$query = "SELECT ARTLANG.idart, ARTLANG.idartlang FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".
$cfg["tab"]["art_lang"]." AS ARTLANG ".
"WHERE CATART.idcat = '$selcat' AND ARTLANG.idart = CATART.idart AND ARTLANG.idlang = '$lang' "." $startarton " ."ARTLANG.online = '1' ORDER BY CATART.idart DESC";
// execute query
$db->query($query);
unset($articleID);
unset($linkID);
// get id's of sub articles
while ($db->next_record()) {
$articleID[] = $db->f("idartlang");
$linkID[] = $db->f("idart");
} // end while
/****************** start table **************************/
echo '
<table border="0" cellpadding="3" cellspacing="0" width="100%"
';
/**** Überschrift der Artikelliste wird ausgegeben, wenn nicht leer ********/
if($print_mainheadline !=""){
echo '
<tr>
<td class="headline"> CMS_VALUE[2] <br></td>
<td align="right"> </td>
</tr>
<tr>
<td bgcolor="#fcf2d5" class="text"> </td>
<td align="right" bgcolor="#fcf2d5"> </td>
</tr>
';
}
// Loop through articles
if (is_array($articleID)) {
foreach ($articleID as $key => $value) {
// select all CMS variables of the article
if($print_headline!="0" && $print_headline!=""){
$sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '1'";
$db->query($sql);
$db->next_record();
$headline = urldecode($db->f("value"));
if ( strlen($headline) > CMS_VALUE[3]) {
$headline = substr($headline , 0, CMS_VALUE[3]);
$headline .= '..';
}
}
if($print_subheadline!="0" && $print_subheadline!=""){
$sql_subheadline = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '2'";
$db->query($sql_subheadline);
$db->next_record();
$subheadline = urldecode($db->f("value"));
if ( strlen($subheadline) > CMS_VALUE[6]) {
$subheadline = substr($subheadline , 0, CMS_VALUE[6]);
$subheadline .= '..';
}
}
/******************* begin thumbnails **********************************/
if($print_thumbnail !="0" && $print_thumbnail !=""){
// select and resolve image path
$imagesql="select value from ".$cfg["tab"]["content"]." where idartlang='$value' and idtype='4' and typeid='1'";
$db2->query($imagesql);
$db2->next_record();
$image_id= $db2->f("value");
// get image name and path
$imagesql="select * from ".$cfg["tab"]["upl"]." where idupl='$image_id'";
$db2->query($imagesql);
$db2->next_record();
$webdir='upload/';
$thumbdir='Vermittlungs-Bilder/thumbnails/';
$filedir='/home/www/web62/html/cms/';
$imagelocation=$filedir.$webdir.$db2->f('dirname').$db2->f('filename');
$thumblocation=$filedir.$webdir.$thumbdir.$db2->f('filename');
if (!file_exists($thumblocation)){
// create thunbnail
$fileinformation=getimagesize($imagelocation);
$imagewidth = $fileinformation[0];
$imageheight = $fileinformation[1];
$imagetype=$db2->f('filetype');
$imageattributes = $fileinformation[3];
//$newfile= $last_id."-image.".$imagetype;
$target=$thumblocation;
if ( !(copy($imagelocation,$target)))
{
echo "Could not copy file to destintaion., Command returned Error Message. Please check your log files. ".$imagelocation." ".$target;
die;
}
//create thumbnails 80xrelational height; neu $thumbnail_width x proportionale Höhe
// Determine what filetype and set pointer to source image
switch ($imagetype)
{
case "gif":
$original_image=imagecreatefromgif($target);
break;
case "png":
$original_image=imagecreatefrompng($target);
break;
case "jpg":
$original_image=imagecreatefromjpeg($target);
break;
}
if (!$original_image){
echo 'Error getting image from '.$target.'.';
}
//echo $target;
// set image width and height of thunbnail and put pointer for filesytsem
$thumbfile= $db2->f('filename');
$target_thumb=$thumblocation;
$t_width=$thumbnail_width;
// calculating height to maintain ratio
$t_height=($thumbnail_width/$imagewidth)*$imageheight;
// remove digits to get solid number
list ($t_height,$notimportand)=explode('.',$t_height);
// create blank image
// $thumb_image=imagecreatetruecolor($t_width,$t_height);
$thumb_image=imagecreate($t_width,$t_height);
// resize image based on height and width
imagecopyresized($thumb_image,$original_image,0,0,0,0,$t_width,$t_height,$imagewidth,$imageheight);
// store image on file system
// requires different functionf for either gif or jpeg
switch ($imagetype)
{
case "gif":
imagegif($thumb_image,$target_thumb);
break;
case "png":
imagepng($thumb_image,$target_thumb);
break;
default:
imagejpeg($thumb_image,$target_thumb,75);
break;
}
imagedestroy($thumb_image);
imagedestroy($original_image);
}
$image=$webdir.$thumbdir.$db2->f('filename');
$imagetag="<img src=\" $image \" border=0>";
} // ende wenn keine thumbs gewünscht
/**************** Ende Thumbnails ***********************/
// link
$link = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$selcat&idart=$linkID[$key]&m=$m&s=$s");
/***********************Anfang Tablezeile für Artikelliste**********************/
echo '
<tr>
<td bgcolor="#ffe699" cellpadding="2" class="subheadline"><A HREF="'.$link.'">'.$headline.'</a></td>
<td width="$thumbnail_width\" align="right" valign="top" bgcolor="#ffe699"><a href="'.$link.'"><img height="22" width="145" src="http://www.tsv-neuss.de/cms/upload/bilder/mehr-infos.gif" border="0"></a></td>
</tr>
<tr>
<td bgcolor="#fcf2d5" class="uebersicht" valign="top">'.$subheadline.'</td>
<td width=\"$thumbnail_width\" align="right" bgcolor="#fcf2d5"><A HREF="'.$link.'">'.$imagetag.'</a></td>
</tr>
<tr><td bgcolor="#ffffff"><IMG SRC="http://www.tsv-neuss.de/cms/bilder/fueller.gif" WIDTH="1" HEIGHT="3"
BORDER="0"></td></tr>
';
} // end while
unset($headline);
unset($subheadline);
} // end foreach
} // end if (is_array)
echo '</table>';
/***********************ende Table**********************/
?>