habe das ursprüngliche Modul mal eben überarbeitet...
Hinweis: Prüft bitte das Layout im Output.... es wurde lediglich auf die schnelle von allen Grafiken befreit und erhebt NICHT den Anspruch noch immer 100% passend zu sein
Neu:
1.) Es zeigt die Artikel rückwirkend bis zum angegebenen Monat (wenn ausgewählt auch in die vergangenenen Jahre bis zum ausgewählten Monat)
2.) Der gewählte Monat BLEIBT auch bei erneutem Aufruf der Template-Bearbeitung erhalten
Code: Alles auswählen
Name des Moduls:
Newsarchiv - chronologisch rückwärts
Beschreibung:
Listet alle News aus einem frei wählbaren Strukturbereich vom aktuellen bis zu einem frei wählbaren Monat und für vergangene Jahre auf
Input:
$Monate =array("1" => "Januar", "2" => "Februar", "3" => "März", "4" => "April", "5" => "Mai", "6" => "Juni", "7" => "Juli", "8" => "August", "9" => "September", "10" => "Oktober", "11" => "November", "12" => "Dezember");
// selected category
$selected = "CMS_VALUE[0]";
echo "<table cellspacing=\"0\" cellpadding=\"5\" border=\"0\">
<tr valign=\"top\">
<td>Kategorie wählen:
<select name=\"CMS_VAR[0]\">";
// fetch all categorys
$query = "SELECT A.idcat, A.level, C.name FROM $cfgTab_cat_tree AS A, ".
"$cfgTab_cat AS B, $cfgTab_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
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>
</td>
</tr>
<tr>
<td>
Vergangene Jahre anzeigen?
<input type=\"checkbox\" name=\"CMS_VAR[6]\" value=\"ja\"";
if ("CMS_VALUE[6]" == "ja") {echo "checked";} echo">ja
</td>
<td>
ab dem Jahr:
<input size=4 maxlength=4 type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\">
</td>
</tr>
<tr valign=\"top\">
<td>Startmonat für ".date("Y")." :
<select name=\"CMS_VAR[5]\">
";
for ($index=1;$index<13;$index=$index+1){
echo "<option value=$index";
if ("CMS_VALUE[5]" != $index)
{
echo ">$Monate[$index]</option>";
}
else
{
echo " selected>$Monate[$index]</option>";
}
}
echo"
</select>
</td>
</tr>
<tr>
<td>
Summary?
<input type=\"checkbox\" name=\"CMS_VAR[4]\" value=\"ja\"";
if ("CMS_VALUE[4]" == "ja") {echo "checked";} echo">ja</td>
<td>
Max Zeichen
<input size=3 maxlength=3 type=\"text\" name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\">
</td>
</tr>
</table>";
Output:
// selected category
$selcat = "CMS_VALUE[0]";
// anzahl der zeichen bei summary
$mxh = "CMS_VALUE[3]";
//summary on/off
$summary_on="CMS_VALUE[4]";
//vergangene Jahre anzeigen?
$early_years="CMS_VALUE[6]";
//aktuelles Jahr
$akt_jahr = date("Y");
if($early_years=="ja")
{
//Startjahr für Archiv
$start_jahr="CMS_VALUE[2]";
}
else
{
$start_jahr=$akt_jahr;
}
$Monate =array("1" => "Januar", "2" => "Februar", "3" => "März", "4" => "April", "5" => "Mai", "6" => "Juni", "7" => "Juli", "8" => "August", "9" => "September", "10" => "Oktober", "11" => "November", "12" => "Dezember");
echo "<table width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
echo "<tr>\n";
echo "<td valign=\"top\" width=\"100%\">\n";
//loop durch die jahre (jahre < aktuelles jahr wird vollständig anzgezeigt)
for ($jahr_index=$akt_jahr;$start_jahr<=$jahr_index;$jahr_index=$jahr_index-1)
{
if ($jahr_index>$start_jahr)
{
if ($akt_jahr==$jahr_index)
{
$max_month=date("m");
$start_monat=1;
}
else
{
$start_monat=1;
$max_month=13;
}
}
//das aktuelle jahr wird von $start_monat bis zum letz. vollst. monat des lfd jahres angezeigt
else
{
$start_monat = "CMS_VALUE[5]";
if ($akt_jahr==$jahr_index)
{
$max_month=date("m");
}
else
{
$max_month=12;
}
}
//loop durch die monate
for ($index=$max_month;$start_monat<=$index;$index=$index-1)
{
echo"<table width=100% border=0 cellspacing=0 cellpadding=0>";
echo" <tr valign=top>\n";
echo" <td width=100%>\n";
echo" <table width=100% border=0 cellspacing=0 cellpadding=0>\n";
echo" <tr>\n";
echo" <td>\n";
echo" <table width=100% height=23 border=0 cellspacing=0 cellpadding=0>\n";
echo" <tr>\n";
echo" <td class=hnews height=23 width=25 valign=center nowrap><font color=#FFFFFF size=2><nobr>$Monate[$index] $jahr_index</nobr></font></td>\n";
echo" </tr>\n";
echo" </table>\n";
echo" </td>\n";
echo" </tr>\n";
// select all articles in category widthout start article
$query = "SELECT ARTLANG.title, ARTLANG.summary, ARTLANG.created, ARTLANG.lastmodified, ARTLANG.idside, ARTLANG.idsidelang FROM $cfgTab_cat_side AS CATART, $cfgTab_side_lang AS ARTLANG WHERE year(ARTLANG.lastmodified)=$jahr_index AND month(ARTLANG.lastmodified)=$index AND CATART.idcat = '$selcat' AND ARTLANG.idside = CATART.idside AND ARTLANG.idlang = '$lang' AND ARTLANG.online = '1' AND CATART.is_start = '0' ORDER BY month(ARTLANG.lastmodified),CATART.idside DESC ";
$db->query($query);
unset($articleID);
unset($linkID);
// get articles
$is_empty=1;
while ($db->next_record())
{
$articleID = $db->f("idsidelang");
$linkID = $db->f("idside");
$link = $sess->url("content.php?client=$client&lang=$lang&idcat=$selcat&idside=$linkID");
$headline = $db->f("title");
$created= date("d.m.y",strtotime($db->f("created")));
$summary = $db->f("summary");
$monat = date("m",strtotime($db->f("lastmodified")));
$jahr =date("Y",strtotime($db->f("lastmodified")));
$len = strlen($summary);
// cut summary if too long
if ($len > $mxh )
{
$summary = substr($summary,0,$mxh);
$summary = $summary . " <a href=\"$link\"><font id=font1>...</font></a>";
}
// HTML template for one element
echo" <tr>\n";
echo" <td colspan=5>\n";
echo" <table border=0 cellspacing=0 cellpadding=0 width=100%>\n";
echo" <tr>\n";
echo" <td width=8 valign=top></td>\n";
echo" <td width=65>\n";
echo" <p><a href=$link><nobr>$created</nobr></a></p>\n";
echo" </td>\n";
echo" <td width=150>\n";
echo" <p><a href=$link><nobr>$headline</nobr></a></p>\n";
echo" </td>\n";
echo" <td width=10>\n";
echo" \n";
echo" </td>\n";
echo" <td width=*>\n";
echo" <p>$summary</p>\n";
echo" </td>\n";
echo" <td width=7 valign=top></td>\n";
echo" </tr>\n";
echo" </table>\n";
echo" </td>\n";
echo" </tr>\n";
unset($headline);
$is_empty=0;
} // end while
if ($is_empty == 1)
{
echo" <tr>\n";
echo" <td colspan=5>\n";
echo" <table border=0 cellspacing=0 cellpadding=0 width=100%>\n";
echo" <tr>\n";
echo" <td>\n";
echo" <p class=hb3>Keine Artikel</p>\n";
echo" </td>\n";
echo" </tr>\n";
echo" </table>\n";
echo" </td>\n";
echo" </tr>\n";
}
// Abschluß der Tabelle
echo" </table>\n";
echo" </td>\n";
echo" </tr>\n";
echo"</table>\n";
}//end for (monate)
}//end for (jahre)
echo " </td>\n";
echo " </tr>\n";
echo"</table>";