Ich habe die Lightbox im Einsatz und alle funktioniert prima.
Doch jetzt bin ich auf ein kleines Problem gestoßen.
Ich habe einen Startartikel angelegt und darin neben einer Menge text einen Link zu einem zweiten Artikel (nicht der Startartikel) in der selben Kategorie angelegt.
Dieser zweite Artikel (nicht der Startartikel) ist die Lightbox-Gallery.
Dort werden dann die ersten 6 von insgesamt 14 Bildern angezeigt.
Über die Navigation , für die ich baghira sehr dankbar bin, sollten dann eigentlich mit Klick auf die Seite 2 die nächsten 6 Bilder und mit Klick auf Seite 3 die übrigen 2 Bilder angezeigt werden.
Leider lande ich bei Klick auf 2 oder 3 immer wieder auf dem Startartikel, der ja nur den Text und denlink auf die Light-Box-gallery enthält.
Wißt Ihr zufällig woran das liegen kann?
Hier der Code:
Input:
Code: Alles auswählen
?>
<table>
<tr>
<td><?php echo mi18n("Breite").' x '.mi18n("Höhe"); ?></td>
<td><input type="text" name="<?php echo "CMS_VAR[0]"; ?>" value="<?php echo "CMS_VALUE[0]"; ?>" style="width:40px;"> x <input type="text" name="<?php echo "CMS_VAR[1]"; ?>" value="<?php echo "CMS_VALUE[1]"; ?>" style="width:40px;"></td>
</tr><tr>
<td><?php echo mi18n("Spalten");?> x <?php echo mi18n("Zeilen");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[2]"; ?>" value="<?php echo "CMS_VALUE[2]"; ?>" style="width:40px;"> x <input type="text" name="<?php echo "CMS_VAR[3]"; ?>" value="<?php echo "CMS_VALUE[3]"; ?>" style="width:40px;"></td>
</tr>
<?php
$sql = "SELECT DISTINCT dirname FROM ".$cfg['tab']['upl']." ORDER BY dirname";
$db->query($sql);
echo '<tr><td>'.mi18n("Verzeichnis auswählen").'</td><td>
<select name="CMS_VAR[4]" size="1" style="width: 320px">
<option value="">'.mi18n("Nichts ausgewählt").'</option>';
while ($db->next_record()) {
if ( stristr($db->f("dirname"),'CVS/') === FALSE ) {
if ($db->f("dirname")=="CMS_VALUE[4]") {
echo '<option value="'.$db->f("dirname").'" selected="selected">'.$db->f("dirname").'</option>';
} else {
echo '<option value="'.$db->f("dirname").'">'.$db->f("dirname").'</option>';
}
}
}
echo '</select></td></tr>';?>
<?php
$sort = "";
if("CMS_VALUE[5]" == "asc" || "CMS_VALUE[5]" == "") {
$asc = " checked";
} else {
$desc = " checked";
}
?>
<tr>
<td><?php echo mi18n("Sortierrichtung");?></td>
<td>
<input type="radio" name="CMS_VAR[5]" value="asc"<?php echo $asc; ?>> <?php echo mi18n("Aufsteigend"); ?>
<input type="radio" name="CMS_VAR[5]" value="desc"<?php echo $desc; ?>> <?php echo mi18n("Absteigend"); ?>
</td>
</tr><tr>
<td><?php echo mi18n("Zeichenanzahl");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[6]"; ?>" value="<?php echo "CMS_VALUE[6]"; ?>" style="width:40px;"></td>
</tr>
</table>
<?php
Output:
Code: Alles auswählen
<?php
cInclude("includes", "functions.api.images.php");
/* Gallery variables */
$bRecursive = false;
/* Input variables */
$iWidth = "CMS_VALUE[0]";
$iHeight = "CMS_VALUE[1]";
if ($iWidth == 0) {
$iWidth = 300;
}
if ($iHeight == 0) {
$iHeight = 300;
}
$iColumns = "CMS_VALUE[2]";
if ($iColumns == 0) {
$iColumns = 2;
}
$iRows = "CMS_VALUE[3]";
if ($iRows == 0) {
$iRows = 2;
}
$sPath = "CMS_VALUE[4]";
if ($sPath=='') {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "bildergalerie/";
} else {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "CMS_VALUE[4]";
}
$sort = "CMS_VALUE[5]";
if( $sort == "asc" ) {
$sort = SORT_ASC;
} else {
$sort = SORT_DESC;
}
$words = "CMS_VALUE[6]";
if (isset($_REQUEST["start"])) {
$iCurrentPage = $_REQUEST["start"];
} else {
$start = 1;
$iCurrentPage = 1;
$_REQUEST["start"] = 1;
}
$aValidExtensions = array("jpg", "jpeg", "gif", "png");
$iImagesPerPage = $iRows * $iColumns;
/* Read all gallery files */
$aGalleryFiles = scanDirectory($sPath, $bRecursive);
array_multisort($aGalleryFiles, $sort, SORT_STRING);
if (is_array($aGalleryFiles)) {
/* Filter out non-images */
foreach ($aGalleryFiles as $key => $aGalleryFile) {
$sExtension = strtolower(getFileExtension($aGalleryFile));
if (!in_array($sExtension, $aValidExtensions)) {
unset($aGalleryFiles[$key]);
}
}
/* Calculate effective variables */
$iFileCount = count($aGalleryFiles);
$iPages = ceil($iFileCount / $iImagesPerPage);
$aImagesToDisplay = array_slice($aGalleryFiles, ($iCurrentPage - 1) * $iImagesPerPage, $iImagesPerPage);
$oImageTpl = new Template;
$oGalleryTpl = new Template;
$oEmptyImageTpl = new Template;
$aRenderedImages = array();
$iRow = 0;
$iImagesRendered = 0;
foreach ($aImagesToDisplay as $sImageToDisplay) {
/* Do Scaling */
$sScaledImage = cApiImgScale($sImageToDisplay, $iWidth, $iHeight);
$sScaledImage = str_replace($cfgClient[$client]["path"]["htmlpath"],"",$sScaledImage);
$link = str_replace($cfgClient[$client]['path']['frontend'],$cfgClient['htmlpath'],$sImageToDisplay);
$media_name = ig_getMedienName($sImageToDisplay);
$link_description = ig_getImageDescription($sImageToDisplay);
if ($words != "" || $words != 0) {
# Cutting text but preserving words and entities
if(strlen($link_description) > $words){
$description = htmlentities(capiStrTrimAfterWord($link_description, $words)."...");
} else {
$description = "";
}
}
if( $media_name != "" && $link_description != "") {
$link_description = $media_name.': '.$link_description;
} elseif( $media_name != "" ) {
$link_description = $link_description;
} elseif( $description != "" ) {
$link_description = $link_description;
$media_name = " ";
}
$oImageTpl->reset();
$oImageTpl->set("s", "FILE", $sScaledImage);
$oImageTpl->set("s", "WIDTH", $iWidth);
$oImageTpl->set("s", "HEIGHT", $iHeight);
$oImageTpl->set("s", "LINK", $link);
$oImageTpl->set("s", "MEDIANAME", $media_name);
$oImageTpl->set("s", "DESCRIPTION", $description);
$oImageTpl->set("s", "LINKDESCRIPTION", $link_description);
$aRenderedImages[] = $oImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_image.html", true, false);
$iImagesRendered++;
if ($iImagesRendered == $iColumns) {
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages));
$oGalleryTpl->next();
$iImagesRendered = 0;
$aRenderedImages = array();
}
}
if (count($aRenderedImages) < $iColumns && count($aRenderedImages) > 0) {
$iEmptyCells = $iColumns - count($aRenderedImages);
$oEmptyImageTpl->set("s", "WIDTH", $iWidth);
$oEmptyImageTpl->set("s", "HEIGHT", $iHeight);
$sEmptyCells = str_repeat($oEmptyImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_empty.html", true, false),$iEmptyCells);
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages) . $sEmptyCells);
$oGalleryTpl->next();
}
$oGalleryTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/bildershow.html", false, false);
##### Neue Navigation START #####
##### Example: Seite 1 von 7
$sPageLinks = '';
echo '<p style="padding-top:10px; text-align:center">';
for ($i = 1; $i <= $iPages; $i++) {
if ($sPageLinks != '') {
$sPageLinks .= '';
}
if ($_REQUEST["start"] == $i) {
$current_page = $_REQUEST["start"];
$sPageLinks .= "Seite $current_page von $iPages\n"; # I'm on the current page, no link
}
}
echo $sPageLinks;
echo '</p>'."\n";
##### Example: |< 1 ... 3 4 5 ... 8 >|
$sPageLinks = '';
echo '<p style="text-align:center">'."\n";
echo '<a href="front_content.php?idcat='.$idcat.'&start=1">'.mi18n("Begin").' |<</a>'."\n";
for ($i = 1; $i <= $iPages; $i++) {
$start = $i;
if ($i == 1 || $i == $iPages) {
if ($sPageLinks != '') {
$sPageLinks .= ' ';
}
if ($_REQUEST["start"] == $start) {
$sPageLinks .= $i."\n"; # I'm on the current page, no link
} else {
$sPageLinks .= '<a href="front_content.php?idcat='.$idcat.'&start='.$start.'">'.$i.'</a>'."\n";
}
} else if ($_REQUEST["start"] == $start) {
$sPageLinks .= ' '.$i."\n"; # I'm on the current page, no link
} else if ($_REQUEST["start"] == ($start + 1)) {
# Front
$sPageLinks .= ' <a href="front_content.php?idcat='.$idcat.'&start='.$start.'">'.$i.'</a>'."\n";
} else if ($_REQUEST["start"] == ($start - 1)) {
# Back
$sPageLinks .= ' <a href="front_content.php?idcat='.$idcat.'&start='.$start.'">'.$i.'</a>'."\n";
} else if ($_REQUEST["start"] == ($start - 2) ||
$_REQUEST["start"] == ($start + 2)) {
$sPageLinks .= '...';
}
}
echo $sPageLinks."\n";
echo ' <a href="front_content.php?idcat='.$idcat.'&start='.ceil($iFileCount / $iImagesPerPage).'">>| '.mi18n("End").'</a>'."\n";
echo '</p>'."\n";
echo '<p style="text-align:center">In dieser Galerie sind '.$iFileCount.' Bilder enthalten.</p>';
##### Neue Navigation ENDE #####
}
function ig_getImageDescription($idupl){
global $cfg, $cfgClient, $db, $client, $lang;
$cApiClient = new cApiClient($client);
$language_separator = $cApiClient->getProperty('language','separator');
if ($language_separator == "") {
//Sanity, if module used in client without set client setting
$language_separator = "???";
$cApiClient->setProperty('language','separator', $language_separator);
}
if(is_numeric($idupl)) {
//ID is a number
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE idupl = ".$idupl;
} else {
//ID is a string
$path_parts = pathinfo($idupl);
$upload = $cfgClient[$client]['upl']['frontendpath'];
$len = strlen($upload);
$pos = strpos($idupl,$upload);
$dirname = substr($path_parts['dirname'],$pos+$len).'/';
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE (dirname = '".$dirname."') AND (filename='".$path_parts['basename']."') AND (filetype='".$path_parts['extension']."')";
}
$db->query($query);
if($db->next_record()) {
return htmlspecialchars(urldecode($db->f("description")));
} else {
return '';
}
}
function ig_getMedienName($idupl) {
global $cfg, $cfgClient, $db, $client, $lang;
$cApiClient = new cApiClient($client);
$language_separator = $cApiClient->getProperty('language','separator');
if ($language_separator == "") {
//Sanity, if module used in client without set client setting
$language_separator = "???";
$cApiClient->setProperty('language','separator', $language_separator);
}
if( is_numeric($idupl) ) {
//ID is a number
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE idupl = ".$idupl;
} else {
//ID is a string
$path_parts = pathinfo($idupl);
$upload = $cfgClient[$client]['upl']['frontendpath'];
$len = strlen($upload);
$pos = strpos($idupl,$upload);
$dirname = substr($path_parts['dirname'],$pos+$len).'/';
$danis = $dirname.$path_parts['basename'];
$query = "SELECT value FROM ".$cfg["tab"]["properties"]." WHERE itemid = '".$dirname.$path_parts['basename']."' AND name = 'medianame'";
}
$db->query($query);
if( $db->next_record() ) {
return htmlspecialchars(urldecode($db->f("value")));
} else {
return '';
}
}
?>
[/code]