NAVIGATION
Die Anzahl der Bilder kann eingestellt werden.
Docu: –
Forum: Display random image from filemanager
Autor: K.Heermann (flip-flop) http://planmatrix.de 2012/03/23
CMS Version: >= V1.39
Version: V1.0
Update: –
Tag: –
Dateiname: random_images.tmpl
Verzeichnis: /template/inc_cntpart/images/
Bedingung: $phpwcms['allow_cntPHP_rt'] = 1; → /config/phpwcms/conf.inc.php —-
Inspiriert durch den Beitrag vom User “breitsch” zu diesem Thema stelle ich hier eine andere generelle Lösung vor, die auf den Templates für “Bilder <div>” oder “Bilder spezial” aufbaut.
Dieses Template kann das vorher gezeigte Zufallsbild (Template) ersetzen.
Es ist eine etwas flexiblerer Ansatz:
<!--IMAGE_SETTINGS_START//--> ; this is formatted like WIN.INI ; please: do not use comments for value lines ; settings will overwrite CP settings ;width = 100 ;height = 100 ;col = 1 ;zoom = 1 ;crop = 0 ;space = 10 ;lightbox = 1 ;nocaption = 0 ; 0 = no center, 1 = horizontal/vertical, 2 = horizontal, 3 = vertical ;center_image = 0 <!--IMAGE_SETTINGS_END//--> <!--IMAGES_HEADER_START//--> <div style="clear:both;"></div> [TITLE]<h3>{TITLE}</h3>[/TITLE] [SUBTITLE]<h4>{SUBTITLE}</h4>[/SUBTITLE] [TEXT]{TEXT}[/TEXT] <div class="images" id="images{ID}"> [PHP] // CUSTOM Input ================ $my_max_count = 0; // Max count of images for output, 0 = all // ============================= $my_images = array(); $my_counter = -1; <!--IMAGES_HEADER_END//--> <!--IMAGES_ENTRY_START//--> $my_counter++; $my_images[$my_counter][0] = '{IMAGE}'; // complete html string with image $my_images[$my_counter][1] = '{IMGID}'; // image-id <!--IMAGES_ENTRY_END//--> <!--IMAGES_ENTRY_SPACER_START//--><!--IMAGES_ENTRY_SPACER_END//--> <!--IMAGES_ROW_SPACER_START//--><!--IMAGES_ROW_SPACER_END//--> <!--IMAGES_FOOTER_START//--> echo '<div class="imageEntryRandom">'.LF; if (!empty($my_images) ) { shuffle($my_images); // new sort if ($my_max_count) { // Max count available? if ($my_max_count <= count($my_images)) { $temp_array = $my_images; $my_images = array_slice($temp_array, 0, $my_max_count); // new random sort order unset ($temp_array); } } foreach ($my_images as $key=>$value) { echo '<div class="imageEntry" id="img'.$my_images[$key][1].'">'.LF; // ID echo ' '.$my_images[$key][0].LF; // thumb and zoom images echo '</div>'.LF; // End imageEntry and ID } } else { // ************* Please insert your fallback image ************* echo '<img src="content/images/my_fallback_image.jpg" width="200" height="150" alt="My alt" title="My title" border="0" />'; } echo '</div>'.LF; // End imageEntryRandom unset ($my_images); unset ($my_counter); unset ($my_max_count); [/PHP] </div> <!--IMAGES_FOOTER_END//-->