ich habe dem standard - Bildmodul "content_image" einen Konfigurations-input Bereich hinzugefügt.
In diesem lässt sich die Anzeigegröße des Bildes einstellen und ein template auswählen, das zur Anzeige verwendet werden soll.
Das ganze ist eher aus der Not heraus geboren, da ich über einigen Artikeln ein Bild anzeigen möchte, welches ich aber auch in anderen Bereichen in anderen Größen verwende.
Eventuell kann es ja einmal jemand brauchen, daher hier mal die Input / Output Codes:
Input:
Code: Alles auswählen
?>
<?php
/***********************************************
* description: standard image
*
* @package Module
* @subpackage ContentImage
* @version SVN Revision $Rev:$
*
* @author marcus.gnass@4fb.de
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
* modify S. Schäfer 28.01.2014
* aply input functions Image size
* aply choose list for template
*/
// find Smarty-Templates which belong to THIS module by scanning the appropriate subdir
$mod = new cApiModule($cCurrentModule);
$tplpath = $cfgClient[$client]["path"]["frontend"]."data/modules/".$mod->get("alias")."/template/";
$tplFiles = scanDirectory($tplpath, $bRecursive);
array_multisort($tplFiles, "SORT_ASC", SORT_STRING);
$sSubmitLink = '<a href="javascript: if (document.tplcfgform.send) {document.tplcfgform.send.value = 0}; document.tplcfgform.submit();"><img class="submitbutton" src="images/submit.gif" title="'.mi18n("Save changes").'" /></a>';
echo '<table>';
echo '<tr>';
echo '<tr><td colspan=2 style="border-left: 1px solid #999999; vertical-align: top;"><strong>'.mi18n("On image side relation 4:3:").'</strong></td></tr>';
echo '<td style="border-left: 1px solid #999999; vertical-align: top;"> <strong>'.mi18n("biggest size of Image").':</strong></td>';
echo '<td><input size="5" type="text" name="CMS_VAR[60]" value="CMS_VALUE[60]"></input></td>';
echo '</tr>';
echo '<tr><td colspan=2 style="border-left: 1px solid #999999; border-bottom: 1px solid #999999; vertical-align: top;">'.mi18n("The image will automatic shown horizontal or vertically").'</td></tr>';
echo '<tr><td style="border-bottom: 1px solid #999999;vertical-align: top;"> <strong>'.mi18n("or manual settings:").':</strong></td><td style="border-bottom: 1px solid #999999;">';
if ("CMS_VALUE[70]" != "true") echo '<input type="checkbox" name="CMS_VAR[70]" value="true"> '.$sSubmitLink;
else echo '<input type="checkbox" name="CMS_VAR[70]" value="true" checked> '.$sSubmitLink;
if (CMS_VALUE[70]) {
echo '<tr>';
echo '<td style="border-left: 1px solid #999999; border-bottom: 1px solid #999999; vertical-align: top;"> <strong>'.mi18n("image width").':</strong></td>';
echo '<td style="border-bottom: 1px solid #999999;"><input size="5" type="text" name="CMS_VAR[71]" value="CMS_VALUE[71]"></input></td>';
echo '</tr>';
echo '<tr>';
echo '<td style="border-left: 1px solid #999999; border-bottom: 1px solid #999999; vertical-align: top;"> <strong>'.mi18n("image height").':</strong></td>';
echo '<td style="border-bottom: 1px solid #999999;"><input size="5" type="text" name="CMS_VAR[72]" value="CMS_VALUE[72]"></input></td>';
echo '</tr>';
}
echo '<tr><td colspan=2 style="border-bottom: 1px solid #999999;">'.mi18n("On empty size-fields the Image will displayed with the original size!").'</td></tr>';
echo '<tr>';
echo '<td style="border-bottom: 1px solid #999999; vertical-align: top;"> <strong>'.mi18n("choose template").'</strong></td>';
echo '<td style="border-bottom: 1px solid #999999;">';
echo '<select name="CMS_VAR[73]" value="CMS_VALUE[73]">';
echo '<option value="">'.mi18n("please_choose").'</option>';
foreach ($tplFiles AS $value) {
$value = str_replace($tplpath, "", $value);
if ($value == $choose) {
echo '<option selected">'.$value.'</option>';
}
else {
echo '<option>'.$value.'</option>';
}
}
echo '</select> '.$sSubmitLink;
echo '</td></tr>';
echo '<tr><td style="border-bottom: 1px solid #999999; vertical-align: top;"><strong>'.mi18n("Your actualy choose:").'</strong></td>';
echo '<td style="border-bottom: 1px solid #999999;"><strong>CMS_VALUE[73]</strong></td></tr>';
echo '<tr><td colspan=2 style="border-bottom: 1px solid #999999;">'.mi18n("If no template selected a standard template will be used!").'</td></tr>';
echo '</table>';
Code: Alles auswählen
<?php
/**
* description: standard image
*
* @package Module
* @subpackage ContentImage
* @version SVN Revision $Rev:$
*
* @author marcus.gnass@4fb.de
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
* modify S. Schäfer 28.01.2014
* aply input functions Image size
* aply choose list for template
*/
// set $template or set a standard template if not choose
$template = "CMS_VALUE[73]";
if ($template == "") {
$template = 'get.tpl';
}
// assert framework initialization
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
// get image source from content type IMG with index 1
$imageSource = "CMS_IMG[1]";
// get description as content type IMGDESCR with index 1
$imageDescription = "CMS_IMGDESCR[1]";
// get editor as content type IMGEDITOR with index 1
// skip IMGEDITOR in frontend cause it displays the image too!
if (cRegistry::isBackendEditMode()) {
$imageEditor = "CMS_IMGEDITOR[1]";
}
// build class containing all data necessary to display image
// therefor the image dimensions have to be determined
if (0 < strlen($imageSource)) {
$clientConfig = cRegistry::getClientConfig(cRegistry::getClientId());
$filename = str_replace($clientConfig["upl"]["htmlpath"], $clientConfig["upl"]["path"], $imageSource);
list($imageWidth, $imageHeight) = getimagesize($filename);
if ($imageWidth > 0) { // if image exists
if ("CMS_VALUE[70]") { // if manual resize selected
$imageWidth = "CMS_VALUE[71]"; //manual ImageWidth
$imageHeight = "CMS_VALUE[72]"; //manual ImageHeight
}
else {
if ("CMS_VALUE[60]") { //if exists a Value "ImageSize"
if ($imageWidth > $imageHeight) {
$imageWidth = "CMS_VALUE[60]";
$imageHeight = ($imageWidth*0.75);
}
else {
$imageHeight = "CMS_VALUE[60]";
$imageWidth = ($imageHeight*0.75);
}
}
}
}//on empty resize fields in configuration will set the oiginal imagesize
$image = new stdClass();
$image->src = $imageSource;
$image->alt = $imageDescription;
$image->width = $imageWidth;
$image->height = $imageHeight;
} else {
$image = NULL;
}
// When in backend edit mode add a label so the author
// knows what to type in the shown field.
if (cRegistry::isBackendEditMode()) {
$label = mi18n("LABEL_IMAGE");
} else {
$label = NULL;
}
// use smarty template to output header text
$tpl = cSmartyFrontend::getInstance();
$tpl->assign('label', $label);
$tpl->assign('editor', $imageEditor);
$tpl->assign('image', $image);
$tpl->display($template);
?>
Code: Alles auswählen
If no template selected a standard template will be used!=Wenn kein Template ausgewählt wird, wird ein standard template verwendet.
LABEL_IMAGE=Bild
On empty size-fields the Image will displayed with the original size!=Wenn Sie keine Größenangaben machen, wird das Bild in Originalgröße dargestellt.
On image side relation 4:3:=Bei Seitenverhältnis 4:3
Save changes=
The image will automatic shown horizontal or vertically=Das Bild wird automatisch horizontal oder vertikal dargestellt!
Your actualy choose:=Ihre aktuelle Auswahl:
biggest size of Image=Größtes Seitenmaß des Bildes
choose template=Vorlage wählen
image height=Bildhöhe
image width=Bildbreite
or manual settings:=oder manuelle Größenangaben
please_choose=Bitte auswählen