da ich nichts passendes gefunden habe, habe ich mir ein kleines Modul geschrieben, welches ich auch hier veröffentlichen möchte - vielleicht kann es ja jemand mal gebrauchen.
Was macht das Modul:
Das Modul erstellt aus allen Artikeln einer Kategorie (inkl. Startartikel) eine kleine Blätternfunktion. Man kann also von einem Artikel zum nächsten klicken.
Dies schaut dann z.B. so aus:
Das Modul
- erstellt einen "Zurück-Link" wenn es nicht die erste Seite ist
- stellt den ersten Artikel mit der Zahl "1" dar, den letzten mit der entsprechenen Zahl - inkl. Link darauf
- stellt die aktuelle Seite als nicht verlinkte Zahl dar
- ergänzt alle Zahlen dazwischen mit einem Platzhalter (frei wählbar)
- erstellt einen "Weiter-Link" wenn es nicht die letzte Seite ist
Ändern kann man dabei folgendes:
- Anzahl der Zahlen die am Anfang und Ende dargestellt werden (bei diesem Beispiel "1")
- Platzhalter (beim diesem Beispiel "..."
- Name des Links "zurück" und "weiter"
- Sortierung
- Sortierreihenfolge
Wozu kann man das Modul benutzen?
z.B. bei einer Bildergalerie, bei der jedes Bild einen eigenen Artikel bekommen soll
Vielen Dank dabei noch an HerrB und Kummer für Teile, die ich aus deren Modulen abgeschrieben habe.
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : artikellaettern
* Author : smac
* Created : 21-09-2006
* Created : 21-09-2006
************************************************/
echo "<table>
<tr>
<td>Anzahl der angezeigten Zahlen (Anfang und Ende):</td>
<td><input type='text' name='CMS_VAR[1]' value='CMS_VALUE[1]'></td>
</tr>
<tr>
<td>Platzhalter:</td>
<td><input type='text' name='CMS_VAR[2]' value='CMS_VALUE[2]'></td>
</tr>
<tr>
<td>Linkname zurück:</td>
<td><input type='text' name='CMS_VAR[3]' value='CMS_VALUE[3]'></td>
</tr>
<tr>
<td>Linkname weiter:</td>
<td><input type='text' name='CMS_VAR[4]' value='CMS_VALUE[4]'></td>
</tr>
<tr>
<td>Sortierung:</td>
<td>
<select name='CMS_VAR[5]'>";
if ("CMS_VALUE[5]" == "ARTLANG.created") {
echo "<option value='ARTLANG.created' selected>Erstelldatum</option>";
} else {
echo "<option value='ARTLANG.created'>Erstelldatum</option>'";
}
if ("CMS_VALUE[5]" == "ARTLANG.lastmodified") {
echo "<option value='ARTLANG.lastmodified' selected>Änderungsdatum</option>";
} else {
echo "<option value='ARTLANG.lastmodified'>Änderungsdatum</option>'";
}
if ("CMS_VALUE[5]" == "ARTLANG.published") {
echo "<option value='ARTLANG.published' selected>Veröffentlichunsdatum</option>";
} else {
echo "<option value='ARTLANG.published'>Veröffentlichunsdatum</option>'";
}
if ("CMS_VALUE[5]" == "ARTLANG.title") {
echo "<option value='ARTLANG.title' selected>Titel (Eigenschaften)</option>";
} else {
echo "<option value='ARTLANG.title'>Titel (Eigenschaften)</option>'";
}
if ("CMS_VALUE[5]" == "ARTLANG.summary") {
echo "<option value='ARTLANG.summary' selected>Zusammenfassung</option>";
} else {
echo "<option value='ARTLANG.summary'>Zusammenfassung</option>'";
}
if ("CMS_VALUE[5]" == "ARTLANG.artsort") {
echo "<option value='ARTLANG.artsort' selected>Sortierung</option>";
} else {
echo "<option value='ARTLANG.artsort'>Sortierung</option>'";
}
echo " </select>
</td>
</tr>
<tr>
<td>Sortierung:</td>
<td>
<select name='CMS_VAR[6]'>";
if ("CMS_VALUE[6]" == "ASC") {
echo "<option value='ASC' selected>aufsteigend</option>";
} else {
echo "<option value='ASC'>aufsteigend</option>'";
}
if ("CMS_VALUE[6]" == "DESC") {
echo "<option value='DESC' selected>absteigend</option>";
} else {
echo "<option value='DESC'>absteigend</option>'";
}
echo " </select>
</td>
</tr>
</table>
";
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : artikellaettern
* Author : smac
* Created : 21-09-2006
* Created : 21-09-2006
************************************************/
$anzahl = "CMS_VALUE[1]";
$platzhalter = "CMS_VALUE[2]";
$zurueck = "CMS_VALUE[3]";
$weiter = "CMS_VALUE[4]";
$sortiert = "CMS_VALUE[5]";
$steigung = "CMS_VALUE[6]";
if ($anzahl=="") $anzahl = 1;
if ($platzhalter=="") $platzhalter = "...";
if ($sortiert=="") $sortiert = "ARTLANG.created";
if ($steigung=="") $steigung= "ASC";
$sql = "SELECT ARTLANG.idart, ARTLANG.title, CATART.idcat, ARTLANG.created
FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".$cfg["tab"]["art_lang"]." AS ARTLANG, ".$cfg["tab"]["cat"]." AS CAT
WHERE CAT.idcat='$idcat'
AND ARTLANG.idart = CATART.idart
AND CATART.idcat = CAT.idcat
AND ARTLANG.idtplcfg = 0
AND ARTLANG.idlang = '$lang'
AND ARTLANG.online = '1'
ORDER BY ".$sortiert." ".$steigung;
$db->query($sql);
if ($db->num_rows() != 0)
{
echo "<div id='uebersicht'>";
$artikel = array(array());
$j=0;
$db->next_record();
$idart_last=$db->f("idart");
for ($i=0; $i<$db->num_rows(); $i++)
{
$artikel[$j][0] = $db->f("idart");
$artikel[$j][1] = $db->f("idcat");
$type = $db->f("idtype");
$typeid = $db->f("typeid");
while ( $idart_last==$db->f("idart") )
{
$idart_last=$db->f("idart");
$db->next_record();
$i++;
}
$idart_last=$db->f("idart");
$j++;
$i--;
}
// Zurückblättern
for ($i=0; $i < $j; $i++)
{
if ($idart==$artikel[$i][0] && $i!=0) {
$x = $i-1;
$zurueck_link ="front_content.php?client=$client&lang=$lang&idcat=".$artikel[$x][1]."&idart=".$artikel[$x][0];
echo "<a href='".$sess->url("$zurueck_link")."'>".$zurueck."</a> ";
}
}
// Zahlen und Platzhalter
for ($i=0; $i < $j; $i++)
{
$k = $i+1;
$navmod_link ="front_content.php?client=$client&lang=$lang&idcat=".$artikel[$i][1]."&idart=".$artikel[$i][0];
if ($idart!=$artikel[$i][0]) {
if ( $k <= $anzahl || $k > $j-$anzahl) {
echo "<a href='".$sess->url("$navmod_link")."'>".$k."</a> ";
}
} else {
if ($k != 1 && $k != 2) { echo $platzhalter." " ; };
echo $k." ";
if ($k != $j-1 && $k != $j) { echo $platzhalter." "; };
}
}
// Weiterblättern
for ($i=0; $i < $j; $i++)
{
if ($idart==$artikel[$i][0] && $i != $j-1) {
$y = $i+1;
$weiter_link ="front_content.php?client=$client&lang=$lang&idcat=".$artikel[$y][1]."&idart=".$artikel[$y][0];
echo "<a href='".$sess->url("$weiter_link")."'>".$weiter."</a> ";
}
}
echo "</div>";
}
?>