Seite 1 von 1

Bild Modul + Fancybox

Verfasst: Do 18. Aug 2011, 13:39
von optimusx
Hallo zusammen

Ich hätte da mal ne frage, ob es das vielleicht gibt btw. was ich machen muss damit es funktioniert.
Ich habe da ein Modul wo man ein Bild auswählen kann was in der entsprechenden "Box" angezeigt werden sollte.
Jetzt würde ich gerne das mit Fancybox verknüpfen, d.h. ich will irgend ein Bild in diese Box speichern und wenn ich auf die Seite gehe, sollte es mit Fancybox rausgezoomt werden können.

Quellcodes :

Modul Input :

Code: Alles auswählen

?><?php
#Selected img directory
$cms_dirname = "CMS_VALUE[1]";
#Selected img
$cms_filename = "CMS_VALUE[2]";

if ($cms_dirname == '' || $cms_dirname == '0') {
    $cms_dirname = 'bilder/';
}

#Get paths
$sql = "SELECT
    htmlpath, frontendpath
    FROM
    ".$cfg["tab"]["clients"]." 
    WHERE
    idclient = ".$client." ";

$db->query($sql);

if ($db->next_record()) {
    $htmlpath = $db->f('htmlpath');
    $frontendpath = $db->f('frontendpath');
}

#Choose image folder
echo '<table cellpadding="0" cellspacing="0" border="0">
    <tr><td class="text_medium" style="padding:5px">'.mi18n("Bildverzeichnis wählen").': </td></tr>
    <tr><td class="text_medium" style="padding:5px">';
echo '<select name="CMS_VAR[1]" style="width:200px">';

#Get upload directories
$sql = "SELECT DISTINCT
    dirname
    FROM
    ".$cfg["tab"]["upl"]."
    WHERE
    idclient='$client' AND
    filetype IN ('jpeg','jpg','gif','png')
    ORDER BY
    dirname";

$db->query($sql);

$selected = false;
while ($db->next_record()) {
    $dirname = $db->f('dirname');
    if ($cms_dirname != $dirname) {
        echo '<option value="'.$dirname.'">&nbsp;'.$dirname.'</option>';
    } else {
        $selected = true;
        echo '<option value="'.$dirname.'" selected="selected">&nbsp;'.$dirname.'</option>';
    }
}

if (!$selected) {
    echo '<option value="0" selected="selected">'.i18n("Bitte wählen").'</option>';
} else {
    echo '<option value="0">'.i18n("Bitte wählen").'</option>';
}

#Choose image file
echo '</select>&nbsp;<input type="image" src="images/submit.gif">
    <tr><td class="text_medium" style="padding:5px">'.mi18n("Bild wählen").': </td></tr>
    <tr><td class="text_medium" style="padding:5px">';
echo '<select name="CMS_VAR[2]" style="width:200px">';
echo '<option value="0" selected="selected">'.i18n("Bitte wählen").'</option>';

if ($cms_dirname != '0') {
    #Get uploaded files
    $sql = "SELECT 
            filename
            FROM
            ".$cfg["tab"]["upl"]."
            WHERE
            idclient = '$client' AND
            filetype IN ('jpeg','jpg','gif','png','swf') AND
            dirname = '$cms_dirname' 
            ORDER BY
            filename";

    $db->query($sql);

    while ($db->next_record()) {
        $img_name = $db->f('filename');
        if ($cms_filename != $img_name) {
            echo '<option value="'.$img_name.'">&nbsp;'.$img_name.'</option>';
        } else {
            echo '<option selected="selected" value="'.$img_name.'">&nbsp;'.$img_name.'</option>';
        }
    }
}

echo '</select>&nbsp;<input type="image" src="images/submit.gif">';

#Preview image
if ($cms_dirname != '0' AND $cms_filename != '0' AND strlen($cms_dirname) > 0 AND strlen($cms_filename) > 0) {
    $img_path = $htmlpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;
    $img_split = preg_split("/\./", $cms_filename);
    $count = count($img_split);
    $type = $img_split[$count -1];

    echo '<tr><td colspan="2" style="padding:5px">      
                <img src="'.$img_path.'">
            </td></tr> ';
}

echo '</td></tr>';
echo '</table>';
?><?php 
Modul Output :

Code: Alles auswählen


<?php
#Selected img directory
$cms_dirname = "CMS_VALUE[1]";
#Selected img
$cms_filename = "CMS_VALUE[2]";

#Default settings
$img_width = 140;
$img_height = 315;


$htmlpath = $cfgClient[$client]['path']['htmlpath'];
$frontendpath = $cfgClient[$client]['path']['frontend'];

$img_path = $htmlpath.$cfgClient[$client]['upload'].$defaultImage;
$img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$defaultImage;

#Check configured images
if ($cms_dirname != '0' AND $cms_filename != '0' AND strlen($cms_dirname) > 0 AND strlen($cms_filename) > 0) {
    $img_path = $htmlpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;
    $img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$cms_dirname.$cms_filename;

    $img_split = preg_split("/\./", $cms_filename);
    $count = count($img_split);
    $type = $img_split[$count -1];

    if (!file_exists($img_path_fs)) {
        $img_path = $htmlpath.$cfgClient[$client]['upload'].$defaultImage;
        $img_path_fs = $frontendpath.$cfgClient[$client]['upload'].$defaultImage;
    }
}

#Scale image
$image = capiImgScale($img_path_fs, $img_width, $img_height, false, false, 10, false);

#Get dimensions of scaled image
list ($width, $height, $type, $attr) = getimagesize(str_replace($cfgClient[$client]["path"]["htmlpath"], $cfgClient[$client]["path"]["frontend"], $image));

#Output image tag
echo '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="'.mi18n("").'" title="'.mi18n("").'"/>';
?>
Layout :

Code: Alles auswählen

....
<div class="bild_gross_2d"><a id="example6" href="">CMS_CONTAINER[510]</a></div>
....

Die Javascript fürs fancybox sind im Layout auch enthalten.
Der Container 510 wäre eben der wo ich ein unterschiedliches Bild mit Fancybox herauszoome kann.
Vllt. muss auch nur etwas in das "href=" reingeschrieben werden.

Danke schon im voraus.

Re: Bild Modul + Fancybox

Verfasst: Do 18. Aug 2011, 13:48
von Oldperl
Hallo optimusx,

zuerst einmal willkommen im CONTENIDO Forum. :)

Bitte benutze zukünftig für Quellcode den Code-Tag des Forums und nicht den Quote-Tag. Danke.
Dein Posting habe ich entsprechend geändert.

Gruß aus Franken

Ortwin

Re: Bild Modul + Fancybox

Verfasst: Do 18. Aug 2011, 22:03
von optimusx
So diese Thread kann geschlossen werden habe es rausgefunden wie ich das vereinen kann. :) "happy"

für leute die es wissen möchten.

Output :


...
Zeile 41 : echo '<a id="example6" href="'.$image.'"><img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="'.mi18n("").'" title="'.mi18n("").'"/></a>';
...