Letztes Update: 2008-09-25
Hi Folks,
nachdem ich im Forum auf kein Modul für das neue Feature gestoßen bin, habe ich mir die Zeit genommen, etwas entsprechendes zu schreiben, und so dem Forum auch endlich etwas beizusteuern und nicht nur immer davon zu profitieren...
Das Modul basiert in der Grundidee auf der Article List Advanced von HerrB. Insbesondere die Inputmaske habe ich aus diesem Modul übernommen, dabei allerdings an einigen Stellen "vereinfacht"...
Der Output wird Template-Basiert generiert, so dass eine Anpassung an das jeweilige Layout möglichst einfach sein sollte.
Um den Modulquelltext möglichst einfach zu halten, habe ich die Funktion zur Generierung des Drop-Down-Menüs mit in die Datei functions.input.helper.php im Mandanten-include-Verzeichnis ausgelagert.
Version 1.0
Grundversion: Konfiguration des Inputs (Auswahl der zu berücksichtigen Felder), Auswahl der auszugebenden ConntentAllocation
Version 1.1
Fehlerkorrektur: Berücksichtigung des Längenfeldes für Texte
Möglichkeit der Auswahl des Templates zur flexibleren Verwendung des Moduls.
Das
Modul hier heruntergeladen werden. Hier findet sich die jeweils aktuellste Version. Für alle, die lieber den Quellcode kopieren, folgt hier der komplette Quellcode:
INPUT
Code: Alles auswählen
/********************************
Modul ContentAllocation - INPUT
Version 1.1
Author: Tilman Jahn, tmj digital
*********************************/
#Includes
cInclude("frontend", "includes/functions.input.helper.php");
# Initialization
$bDebug = false;
$iDataStart = 20;
$sSubmitLink = '<a href="javascript:if (document.tplcfgform.send) {document.tplcfgform.send.value = 0}; document.tplcfgform.submit();"><img src="images/submit.gif" /></a>';
unset ($aSettings);
# Base settings
$aSettings = array();
$aSettings["ArticleCount"] = "CMS_VALUE[0]";
$aSettings["ArticlePerPage"] = "CMS_VALUE[1]";
$aSettings["SortBy"] = "CMS_VALUE[2]";
$aSettings["SortDir"] = "CMS_VALUE[3]";
$aSettings["ShowStart"] = "CMS_VALUE[4]";
$aSettings["Category"] = "CMS_VALUE[5]";
$aSettings["SampleCat"] = "CMS_VALUE[12]";
$aSettings["SampleArt"] = "CMS_VALUE[6]";
$aSettings["HeadlineIdentifier"] = "CMS_VALUE[7]";
$aSettings["HeadlineLength"] = "CMS_VALUE[8]";
$aSettings["Elements"] = "CMS_VALUE[9]";
$aSettings["CatTypeSel"] = "CMS_VALUE[10]";
$aSettings["AddCats"] = "CMS_VALUE[11]";
# Checking base settings
if (!is_numeric($aSettings["ArticleCount"]) || $aSettings["ArticleCount"] < 0) {
$aSettings["ArticleCount"] = 5;
}
if (!is_numeric($aSettings["ArticlePerPage"]) || $aSettings["ArticlePerPage"] < 0) {
$aSettings["ArticlePerPage"] = 0; // Deactivating page browsing
}
if (!is_numeric($aSettings["Category"]) || $aSettings["Category"] <= 0) {
$aSettings["Category"] = 0;
}
if (!is_numeric($aSettings["SampleCat"]) || $aSettings["SampleCat"] <= 0) {
$aSettings["SampleCat"] = $aSettings["Category"];
}
if (!is_numeric($aSettings["SampleArt"]) || $aSettings["SampleArt"] < 0) {
$aSettings["SampleArt"] = 0;
}
if (strlen($aSettings["HeadlineIdentifier"]) > 50) {
$aSettings["HeadlineIdentifier"] = "";
}
if (!is_numeric($aSettings["HeadlineLength"]) || $aSettings["HeadlineLength"] < 0) {
$aSettings["HeadlineLength"] = 0;
}
if (!is_numeric($aSettings["Elements"]) || $aSettings["Elements"] < 0) {
$aSettings["Elements"] = 0;
}
if ($aSettings["CatTypeSel"] == "" || ($aSettings["AddCats"] == "" && $aSettings["CatTypeSel"] == "selected")) {
$aSettings["CatTypeSel"] = "none";
}
# Detail settings
if ($aSettings["Elements"] > 0) {
for ($i = 0; $i < $aSettings["Elements"]; $i++) {
$iElementType = $iDataStart + ($i * 5);
$iElementIdentifier = $iElementType + 1;
$iElementWidth = $iElementType + 2;
$iElementHeight = $iElementType + 3;
$aSettings["k".$i] = array();
$aSettings["k".$i]["ElementType"] = "CMS_VALUE[$iElementType]"; // Text, Image, ExtractedImage
$aSettings["k".$i]["Identifier"] = "CMS_VALUE[$iElementIdentifier]";
$aSettings["k".$i]["ElementWidth"] = "CMS_VALUE[$iElementWidth]"; // Textlength or ImageWidth
$aSettings["k".$i]["ElementHeight"] = "CMS_VALUE[$iElementHeight]";
# Check detail settings
if ($aSettings["k".$i]["ElementType"] == "") {
$aSettings["k".$i]["ElementType"] == "Text";
}
if ($aSettings["k".$i]["ElementType"] == "Text") {
$aSettings["ElementHeight"] = 0;
if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] < 0) {
$aSettings["k".$i]["ElementWidth"] = 50;
}
} else if (!is_numeric($aSettings["k".$i]["ElementWidth"]) || $aSettings["k".$i]["ElementWidth"] <= 0 ||
!is_numeric($aSettings["k".$i]["ElementHeight"]) || $aSettings["k".$i]["ElementHeight"] <= 0) {
$aSettings["k".$i]["ElementWidth"] = 0;
$aSettings["k".$i]["ElementHeight"] = 0;
}
if (strlen($aSettings["Identifier"]) > 50) {
$aSettings["Identifier"] = "";
}
}
}
echo ' <table cellspacing="0" cellpadding="2" border="0" width="100%">'."\n";
echo ' <tr>'."\n";
echo ' <td class="text">'.mi18n("Primary Content Allocation Category:").'</td>'."\n";
//echo ' <td class="text">'.fncBuildCategorySelect("CMS_VAR[5]", $aSettings["Category"], 0, "").'</td>'."\n";
echo ' <td class="text">'.buildAllocationSelect("CMS_VAR[5]", $aSettings["Category"], "", "1").'</td>'."\n";
echo ' </tr>'."\n";
echo ' <tr>'."\n";
echo ' <td class="text" style="vertical-align: top;">'.mi18n("Additional Categories:").'</td>'."\n";
echo ' <td class="text">';
if ($aSettings["CatTypeSel"] == "none") {
echo '<input type="radio" name="CMS_VAR[10]" value="none" checked="checked" onclick="document.getElementsByName(\'c'.$cnumber.'cbxAddCatSel\')[0].disabled = true;">'.mi18n("None").' ';
} else {
echo '<input type="radio" name="CMS_VAR[10]" value="none" onclick="document.getElementsByName(\'c'.$cnumber.'cbxAddCatSel\')[0].disabled = true;">'.mi18n("None").' ';
}
if ($aSettings["CatTypeSel"] == "below") {
echo '<input type="radio" name="CMS_VAR[10]" value="below" checked="checked" onclick="document.getElementsByName(\'c'.$cnumber.'cbxAddCatSel\')[0].disabled = true;">'.mi18n("All below primary").' ';
} else {
echo '<input type="radio" name="CMS_VAR[10]" value="below" onclick="document.getElementsByName(\'c'.$cnumber.'cbxAddCatSel\')[0].disabled = true;">'.mi18n("All below primary").' ';
}
echo ' </tr>'."\n";
echo ' <tr>'."\n";
echo ' <td class="text">'.mi18n("Sort by:").'</td>'."\n";
echo ' <td class="text"><select name="CMS_VAR[2]">'."\n";
if ($aSettings["SortBy"] == "" || $aSettings["SortBy"] == "CATART.idart") {
echo ' <option value="ARTLANG.idart" selected>'.mi18n("Article ID").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.idart">'.mi18n("Article ID").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.created") {
echo ' <option value="ARTLANG.created" selected>'.mi18n("Add Date").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.created">'.mi18n("Add Date").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.lastmodified") {
echo ' <option value="ARTLANG.lastmodified" selected>'.mi18n("Last Modified Date").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.lastmodified">'.mi18n("Last Modified Date").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.published") {
echo ' <option value="ARTLANG.published" selected>'.mi18n("Published Date").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.published">'.mi18n("Published Date").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.title") {
echo ' <option value="ARTLANG.title" selected>'.mi18n("Page Title (Backend)").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.title">'.mi18n("Page Title (Backend)").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.pagetitle") {
echo ' <option value="ARTLANG.pagetitle" selected>'.mi18n("Page Title (Frontend)").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.pagetitle">'.mi18n("Page Title (Frontend)").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.summary") {
echo ' <option value="ARTLANG.summary" selected>'.mi18n("Summary (Backend)").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.summary">'.mi18n("Summary (Backend)").'</option>'."\n";
}
if ($aSettings["SortBy"] == "ARTLANG.artsort") {
echo ' <option value="ARTLANG.artsort" selected>'.mi18n("Sort No.").'</option>'."\n";
} else {
echo ' <option value="ARTLANG.artsort">'.mi18n("Sort No.").'</option>'."\n";
}
echo ' </select>'."\n";
if ($aSettings["SortDir"] != "DESC") {
echo ' <input type="radio" name="CMS_VAR[3]" value="ASC" checked>'.mi18n("Ascending").' <input type="radio" name="CMS_VAR[3]" value="DESC">'.mi18n("Descending")."\n";
} else {
echo ' <input type="radio" name="CMS_VAR[3]" value="ASC">'.mi18n("Ascending").' <input type="radio" name="CMS_VAR[3]" value="DESC" checked>'.mi18n("Descending")."\n";
}
echo ' </tr>'."\n";
echo ' </table>'."\n";
echo ' <table cellspacing="0" cellpadding="2" border="0" width="100%">'."\n";
echo ' <tr>'."\n";
echo ' <td colspan="2" class="textw_medium" style="background-color: #a9aec2; border: 1px solid #747488;">'.mi18n("Identify elements:").'</td>'."\n";
echo ' </tr>'."\n";
echo ' <tr>'."\n";
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Sample Category:").'</td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildCategorySelect("CMS_VAR[12]", $aSettings["SampleCat"], 0, "if (document.forms[0].elements['CMS_VAR[12]'].value != 'CMS_VALUE[12]') { document.forms[0].elements['CMS_VAR[6]'].disabled = true; document.forms[0].elements['CMS_VAR[7]'].disabled = true; document.forms[0].elements['CMS_VAR[8]'].disabled = true; document.forms[0].elements['CMS_VAR[9]'].disabled = true; } else { document.forms[0].elements['CMS_VAR[6]'].disabled = false; document.forms[0].elements['CMS_VAR[7]'].disabled = false; document.forms[0].elements['CMS_VAR[8]'].disabled = false; document.forms[0].elements['CMS_VAR[9]'].disabled = false;}").' '.$sSubmitLink.'</td>'."\n";
echo ' </tr>'."\n";
echo ' <tr>'."\n";
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Sample Article:").'</td>'."\n";
if ($aSettings["SampleCat"] == 0) {
$sDisabled = "disabled";
} else {
$sDisabled = "";
}
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildArticleSelect("CMS_VAR[6]", $aSettings["SampleCat"], $aSettings["SampleArt"], "if (document.forms[0].elements['CMS_VAR[6]'].value != 'CMS_VALUE[6]') { document.forms[0].elements['CMS_VAR[7]'].disabled = true; document.forms[0].elements['CMS_VAR[8]'].disabled = true; document.forms[0].elements['CMS_VAR[9]'].disabled = true; } else { document.forms[0].elements['CMS_VAR[7]'].disabled = false; document.forms[0].elements['CMS_VAR[8]'].disabled = false; document.forms[0].elements['CMS_VAR[9]'].disabled = false;}", $sDisabled).' '.$sSubmitLink.'</td>'."\n";
echo ' </tr>'."\n";
echo ' <tr>'."\n";
echo ' <td class="text" style="border-left: 1px solid #747488;">'.mi18n("Headline Element:").'</td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;">'.fncBuildTypeSelect("CMS_VAR[7]", $aSettings["SampleArt"], $aSettings["HeadlineIdentifier"], "'1','2','3','9','17'").' '.mi18n("Length (max.):").'</td>'."\n";
echo ' </tr>'."\n";
if ($aSettings["Elements"] == 0) {
$sBottomStyle = "border-bottom: 1px solid #747488;"; // Paint the table area closing line
} else {
$sBottomStyle = "";
}
echo ' <tr>'."\n";
echo ' <td class="text" style="border-left: 1px solid #747488;'.$sBottomStyle.'">'.mi18n("Additional elements:").'</td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;'.$sBottomStyle.'"><input type="text" name="CMS_VAR[9]" value="'.$aSettings["Elements"].'" size="3" title="'.mi18n("Set to a value above 0 to specify text or images as additional elements").'"> '.$sSubmitLink.'</td>'."\n";
echo ' </tr>'."\n";
if ($aSettings["Elements"] > 0) {
for ($i = 0; $i < $aSettings["Elements"]; $i++) {
$iElementType = $iDataStart + ($i * 5);
$iElementIdentifier = $iElementType + 1;
$iElementWidth = $iElementType + 2;
$iElementHeight = $iElementType + 3;
echo ' <tr>'."\n";
echo ' <td class="text" style="border-left: 1px solid #747488;padding-left: 20px;vertical-align: top;">'.sprintf(mi18n("%s. Element:"), $i + 1).'</td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;">'.mi18n("Type:").'<br />'."\n";
echo ' <select name="'."CMS_VAR[$iElementType]".'" onchange="if (document.forms[0].elements[\''."CMS_VAR[$iElementType]".'\'].value != \''.$aSettings["k".$i]["ElementType"].'\') { document.forms[0].elements[\''."CMS_VAR[$iElementIdentifier]".'\'].disabled = true; document.forms[0].elements[\''."CMS_VAR[$iElementWidth]".'\'].disabled = true; if (document.forms[0].elements[\''."CMS_VAR[$iElementHeight]".'\']) {document.forms[0].elements[\''."CMS_VAR[$iElementHeight]".'\'].disabled = true;}} else { document.forms[0].elements[\''."CMS_VAR[$iElementIdentifier]".'\'].disabled = false; document.forms[0].elements[\''."CMS_VAR[$iElementWidth]".'\'].disabled = false; if (document.forms[0].elements[\''."CMS_VAR[$iElementHeight]".'\']) {document.forms[0].elements[\''."CMS_VAR[$iElementHeight]".'\'].disabled = false;}}"">'."\n";
if ($aSettings["k".$i]["ElementType"] == "Text") {
echo ' <option value="Text" selected="selected">'.mi18n("Text").'</option>'."\n";
} else {
echo ' <option value="Text">'.mi18n("Text").'</option>'."\n";
}
if ($aSettings["k".$i]["ElementType"] == "Image") {
echo ' <option value="Image" selected="selected">'.mi18n("Image").'</option>'."\n";
} else {
echo ' <option value="Image">'.mi18n("Image").'</option>'."\n";
}
echo ' </select> '.$sSubmitLink.' '."\n";
echo ' </td>'."\n";
echo ' </tr>'."\n";
if ($i == ($aSettings["Elements"] - 1)) {
$sBottomStyle = "border-bottom: 1px solid #747488;"; // Paint the table area closing line
} else {
$sBottomStyle = "";
}
echo ' <tr>'."\n";
switch ($aSettings["k".$i]["ElementType"]) {
case "Image":
echo ' <td class="text" style="border-left: 1px solid #747488;'.$sBottomStyle.'padding-left: 20px;"> </td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;'.$sBottomStyle.'">'.mi18n("Item:").'<br />'.fncBuildTypeSelect("CMS_VAR[$iElementIdentifier]", $aSettings["SampleArt"], $aSettings["k".$i]["Identifier"], "'4'").' '."\n";
echo ' '.mi18n("Width:"). ' <input type="text" name="'."CMS_VAR[$iElementWidth]".'" value="'.$aSettings["k".$i]["ElementWidth"].'" size="4" title="'.mi18n("Set to 0 to disable resize").'"> '."\n";
echo ' '.mi18n("Height:").' <input type="text" name="'."CMS_VAR[$iElementHeight]".'" value="'.$aSettings["k".$i]["ElementHeight"].'" size="4" title="'.mi18n("Set to 0 to disable resize").'"></td>'."\n";
break;
default:
echo ' <td class="text" style="border-left: 1px solid #747488;'.$sBottomStyle.'padding-left: 20px;"> </td>'."\n";
echo ' <td class="text" style="border-right: 1px solid #747488;'.$sBottomStyle.'">'.mi18n("Item:").'<br />'.fncBuildTypeSelect("CMS_VAR[$iElementIdentifier]", $aSettings["SampleArt"], $aSettings["k".$i]["Identifier"], "'1','2','3','9','17'").' '."\n";
echo ' '.mi18n("Length (max.):").' <input type="text" name="'."CMS_VAR[$iElementWidth]".'" value="'.$aSettings["k".$i]["ElementWidth"].'" size="3" title="'.mi18n("Set to 0 to show all").'"></td>'."\n";
}
echo ' </tr>'."\n";
}
}
echo ' </tr>'."\n";
echo "<tr><td>HTML-Tags nutzen?</td><td><input type=checkbox name='CMS_VAR[102]' value='use'";
if ("CMS_VALUE[102]" == "use")
echo " checked";
echo "></td></tr>\n";
echo "<tr><td>Template</td><td><input type=text name='CMS_VAR[103]' value='CMS_VALUE[103]'></td></tr>\n";
echo ' </table>'."\n";
OUTPUT
Code: Alles auswählen
<?PHP
/********************************
Modul ContentAllocation - OUTPUT
Version 1.1
Author: Tilman Jahn, tmj digital
*********************************/
$sOrder = "CMS_VALUE[2]";
$sOrderDirection = "CMS_VALUE[3]";
$vElementIdentifier = "CMS_VALUE[7]";
$sSelectedPica = "CMS_VALUE[5]";
$sNumElement = "CMS_VALUE[9]";
$sMoreCategories = "CMS_VALUE[10]";
$htmltags = "CMS_VALUE[102]";
$sTemplate = "CMS_VALUE[103]";
if ($sTemplate == "")
$sTemplate = "pica.html";
$dataStart = 20;
$align="left";
$fieldcount = 1;
$db = new DB_Contenido;
$db2 = new DB_Contenido;
$db3 = new DB_Contenido;
if (!isset($tpl) || !is_object($tpl)) {
$tpl = new Template();
}
function getChildPicas($parent) {
global $cfg, $lang;
$db4 = new DB_Contenido;
$sql4 = "SELECT LANG.idpica_alloc as id FROM ".$cfg["tab"]["pica_alloc"]." AS ALLOC JOIN ".$cfg["tab"]["pica_lang"]." AS LANG ON ALLOC.idpica_alloc=LANG.idpica_alloc WHERE ALLOC.parentid=$parent AND LANG.online=1";
$db4->query($sql4);
if ($db4->num_rows() > 0) {
while ($db4->next_record()) {
$picas .= ",".$db4->f("id").getChildPicas($db4->f("id"));
}
}
return $picas;
}
$sql = "SELECT online FROM ".$cfg["tab"]["pica_lang"]." WHERE idpica_alloc=$sSelectedPica";
$db->query($sql);
$db->next_record();
if ($db->f("online") == 0)
$sSelectedPica = 0;
// Getting all relevant allocations:
if ($sMoreCategories == "below" && $sSelectedPica != 0) {
$picas = "($sSelectedPica".getChildPicas($sSelectedPica).")";
}
else {
$picas = "($sSelectedPica)";
}
// Getting list of all relevant articles (ordered by selected ordering)
$sql = "SELECT pica.idartlang as idartlang, ARTLANG.idart as idart, ARTLANG.idlang as idlang FROM ".$cfg["tab"]["pica_alloc_con"]." AS pica JOIN ".$cfg["tab"]["art_lang"]." AS ARTLANG ON pica.idartlang=ARTLANG.idartlang WHERE pica.idpica_alloc IN $picas AND ARTLANG.online=1 ORDER BY $sOrder $sOrderDirection";
$db->query($sql);
if ($db->num_rows() > 0) {
while ($db->next_record()) {
//preparing Template
$tpl->reset();
$fieldcount=1;
$vElementIdentifier = "CMS_VALUE[7]";
$sql2 = "SELECT value FROM ".$cfg["tab"]["content"]." AS tblData WHERE idartlang=".$db->f("idartlang")." AND ".$vElementIdentifier;
$db2->query($sql2);
while ($db2->next_record())
{
// Set Value in Template
$fieldname = 'field0';
$title = urldecode($db2->f("value"));
$tpl->set('s',$fieldname,$title);
}
// Reading elements for each relevant article
for ($i=0;$i<$sNumElement;$i++) {
$iElementType = $dataStart + ($i*5);
$iElementIdentifier = $iElementType + 1;
$iElementWidth = $iElementType + 2;
$iElementHeight = $iElementType + 3;
$vElementIdentifier = "CMS_VALUE[$iElementIdentifier]";
$vElementType = "CMS_VALUE[$iElementType]";
$vElementWidth = "CMS_VALUE[$iElementWidth]";
// reading record for each predefined element of the article
$sql2 = "SELECT value FROM ".$cfg["tab"]["content"]." AS tblData WHERE idartlang=".$db->f("idartlang")." AND ".$vElementIdentifier;
$db2->query($sql2);
$fieldname = "field".$fieldcount;
if ($db2->num_rows() == 0)
$tpl->set('s',$fieldname,"");
while ($db2->next_record())
{
if ($vElementType == "Image") {
// Reading information about image
$vElementHeight = "CMS_VALUE[$iElementHeight]";
$sql3 = "SELECT filename, dirname FROM ".$cfg["tab"]["upl"]." WHERE idupl=".$db2->f("value");
$db3->query($sql3);
if ($db3->num_rows() > 0) {
$db3->next_record();
$webpath = $cfgClient[$client]["upl"]["htmlpath"].$db3->f("dirname").$db3->f("filename");
$serverpath = $cfgClient[$client]["upl"]["path"].$db3->f("dirname").$db3->f("filename");
$image = $webpath;
list ($width, $height, $type, $attr) = getimagesize($webpath);
if (file_exists($serverpath) && $width > $vElementWidth && $height > $vElementHeight) {
$image = capiImgScale($serverpath,$vElementWidth, $vElementHeight, false, false, 10, false);
list ($width, $height, $type, $attr) = getimagesize($image);
}
$align == "left"?$marginentry = 'style="margin-right:5px; margin-bottom:5px;"':$marginentry = 'style="margin-left:5px; margin-bottom:5px;"';
$imagetag = "<img src='$image' width=$width height=$height align=$align $marginentry />";
$tpl->set('s',$fieldname,$imagetag);
$tpl->set('s','minheight',$height);
}
else {
echo $sql3;
}
}
else {
$htmltags == "use"?$temp = html_entity_decode(urldecode($db2->f("value"))):$temp = html_entity_decode(strip_tags(urldecode($db2->f("value"))));
if ($vElementWidth>0 && strlen($temp)>$vElementWidth) {
$temp = capiStrTrimAfterWord($temp,$vElementWidth)."...";
}
$tpl->set('s',$fieldname,$temp);
}
}
// switching aling of image
//$align == "left"? $align = "right":$align="left";
$fieldcount++;
} // end for
$link = "front_content.php?idart=".$db->f("idart")."&lang=".$db->f("idlang");
$tpl->set('s','link',$link);
$tpl->generate('templates/'.$sTemplate);
} // end while next_record(), $sql
}
?>
Neben der Moduldatei werden folgende zusätzliche Funktionen in der Datei functions.input.helper.php (abzulegen im includes-Verzeichnis des Mandanten) benötigt:
Code: Alles auswählen
function listOptionsAllocation($parent = 0, $language, $level = 0, $sSelected) {
global $cfg, $client, $lang, $idcat;
$html = "";
$db = new DB_Contenido;
$sql = "";
$sql = "SELECT a.idpica_alloc as idpica_alloc, a.name as name FROM ".$cfg["tab"]["pica_lang"]." AS a JOIN ".$cfg["tab"]["pica_alloc"]." AS b on a.idpica_alloc=b.idpica_alloc WHERE b.parentid = $parent AND a.idlang=$lang ORDER BY b.sortorder asc";
$db->query($sql);
if ($db->num_rows() == 0) {
return "";
}
$sArray = explode(",",$sSelected);
while ($db->next_record()) {
$html .= '<option value="'.$db->f("idpica_alloc").'"';
if (in_array($db->f("idpica_alloc"),$sArray))
$html .= " selected";
$html .= '>'."\n";
for ($i=0;$i<$level;$i++) {
$html .= " ";
}
$html .= ">".$db->f("name")."</option>";
$html .= listOptionsAllocation($db->f("idpica_alloc"),$language,$level+1, $sSelected);
}
unset ($db2);
unset ($sql);
return $html;
}
function buildAllocationSelect($varName, $varValue, $sType = '', $sSize = '1') {
$html = "";
$html .= '<SELECT name="'.$varName.'" '.$sType.' size='.$sSize.'>'."\n";
$html .= ' <option value="">Bitte wählen....</option>'."\n";
$html .= listOptionsAllocation(0,$lang, 0, $varValue);
$html .= "</SELECT>";
return $html;
}
Beispiel für ein Template:
Code: Alles auswählen
<div>
<h3>{field0}</h3>
<h2>{field1}</h2><div id="area2"style="min-height:{minheight}px;">{field2}
{field3}
</div><div align=right style="height:17px; margin-top:15px; margin-right:25px;"><a class="mylink" href="{link}">{field0} [+]</a></div>
<div class="toplink" style="margin-bottom:25px;"><a href="#top"><img src="!imgs/framework/top.gif" alt="Zum Seitenanfang" title="Zum Seitenanfang" border=0 /></a></div></div>
Die Felder 'link' und 'height' werden gesondert behandelt und Standardmäßig gesetzt. height wird durch die Höhe des Bildes bestimmt, link automatisch generiert.
Wer Fehler findet, möge sie bitte nicht behalten sondern korrigieren und hier posten!
Ein ganz herzliches Dankeschön an HerrB, der mit seiner Artikelliste eine wunderbare Vorlage geliefert hat, die in meinem Projekt seit Jahren ihren besten Dienst tut!
Viele Grüße und viel Erfolg beim Testen meines Moduls
tmj