Slider

Einfacher Bilder-Slider mit Template- und CSS Dateien

Voraussetzung: mootools 1.1.x oder mootools 1.2.x

Frontendausgabe mit LightBox

Ausgabe im FE: Slider

Backend

LightBox: ein, Effekt 1/3: ein, zuschneiden Thumb 95×115: ein

Backend


Template mootools V1.1.x

/template/inc_cntpart/imagespecial/slider_new_11x.tmpl

/template/inc_cntpart/imagespecial/slider_new.tmpl

<!--IMAGES_HEADER_START//-->
 
[TITLE]<h1>{TITLE}</h1>[/TITLE]
[SUBTITLE]<h2>{SUBTITLE}</h2>[/SUBTITLE]
[TEXT]{TEXT}[/TEXT]
 
    [EFFECT_1][Ich bin der Effekt 1] : [/EFFECT_1]
    [EFFECT_2][Ich bin der Effekt 2] : [/EFFECT_2]
    [EFFECT_3][Ich bin der Effekt 3]<br />[/EFFECT_3]
 
<div class="slider" id="slider_container_{ID}">
  <div id="slider_{ID}" class="inner">
<!--IMAGES_HEADER_END//-->
 
 
<!--IMAGES_ENTRY_START//-->
    [ZOOM]<a href="{IMAGE_ABS}" title="{INFOTEXT}" target="_blank"{LIGHTBOX}><img src="{THUMB_ABS}" alt="{CAPTION}" border="0" /><br />
<span class="thumb_capture">{INFOTEXT}</span></a>
[/ZOOM][ZOOM_ELSE]
    [IMAGE_URL]<a href="{IMAGE_URL}"{IMAGE_TARGET}>[/IMAGE_URL]<img src="{THUMB_ABS}" alt="{THUMB_NAME}" border="0" />[IMAGE_URL]</a>[/IMAGE_URL]
[/ZOOM_ELSE]
<!--IMAGES_ENTRY_END//-->
 
 
<!--IMAGES_ENTRY_SPACER_START//--><!--IMAGES_ENTRY_SPACER_END//-->
 
 
<!--IMAGES_ROW_SPACER_START//--><!--IMAGES_ROW_SPACER_END//-->
 
 
<!--IMAGES_FOOTER_START//-->
  </div>
</div>
<a href="#" id="move_left_{ID}">&laquo; Left &laquo;</a> | <a href="#" id="move_right_{ID}">&raquo; Right &raquo;</a>
 
 
[PHP]
 
  $GLOBALS['block']['css']['slider_{ID}'] = 'specific/slider_new.css';
 
  $GLOBALS['block']['custom_htmlhead']['slider_{ID}'] = '  <script type="text/javascript">
  <!--
 
  window.addEvent(\'domready\', function(){
 
    var slider_width  = 0;
    var step      = 106;
    var scroll_x    = 0;
    var slider_parent = $(\'slider_container_{ID}\').getSize().size.x;
 
    $$(\'div.slider a\').each( function(e) {
 
      slider_width += e.getSize().size.x + 5;
 
    });
 
    var scroll = new Fx.Scroll(\'slider_container_{ID}\', {
      wait: false,
      duration: 550,
      offset: {\'x\': 0, \'y\': 0},
      transition: Fx.Transitions.Quad.easeOut
    });
 
    scroll.scrollTo(0, 0);
 
    $(\'move_right_{ID}\').addEvent(\'click\', function(event) {
      event = new Event(event).stop();
      if(slider_width-slider_parent <= scroll_x) {
        scroll_x = scroll_x - 106;
      }
      scroll_x = scroll_x + 106;
      scroll.scrollTo(scroll_x, 0);
    });
 
    $(\'move_left_{ID}\').addEvent(\'click\', function(event) {
      event = new Event(event).stop();
      scroll_x = scroll_x - 106;
      if(scroll_x < 0) {
        scroll_x = 0;
      }
      scroll.scrollTo(scroll_x, 0);
    });
 
 
  });
 
  //-->
  </script>';
 
[/PHP]
<!--IMAGES_FOOTER_END//-->


Template mootools V1.2.x

<note important> Für die Verwendung mit den Mootools V1.2.x wurde das Skript erweitert um

Fx.Scroll.implement({
  scrollTo: function(y, x){
  return this.start(y, x);
  }
});

und alle

getSize().size 

ersetzt durch

getSize()

</note>

Update 15.06.2010 KH:

  • Zeile in [ZOOM_ELSE]….[/ZOOM_ELSE] korrigiert, da im JS auf ”<a …” getriggert wird. (Siehe hierzu Unterschied zum Originaltemplate).
  • Aufruf FX.Scroll nach [PHP]… ausgelagert, da Reihenfolge der Scripte nicht optimal.


/template/inc_cntpart/imagespecial/slider_new_12x.tmpl

/template/inc_cntpart/imagespecial/slider_new_12x.tmpl

<!--IMAGES_HEADER_START//-->
 
[TITLE]<h1>{TITLE}</h1>[/TITLE]
[SUBTITLE]<h2>{SUBTITLE}</h2>[/SUBTITLE]
[TEXT]{TEXT}[/TEXT]
 
    [EFFECT_1][Ich bin der Effekt 1] : [/EFFECT_1]
    [EFFECT_2][Ich bin der Effekt 2] : [/EFFECT_2]
    [EFFECT_3][Ich bin der Effekt 3]<br />[/EFFECT_3]
 
<div class="slider" id="slider_container_{ID}">
  <div id="slider_{ID}" class="inner">
<!--IMAGES_HEADER_END//-->
 
 
<!--IMAGES_ENTRY_START//-->
    [ZOOM]<a href="{IMAGE_ABS}" title="{INFOTEXT}" target="_blank"{LIGHTBOX}><img src="{THUMB_ABS}" alt="{CAPTION}" border="0" /><br />
<span class="thumb_capture">{INFOTEXT}</span></a>
[/ZOOM][ZOOM_ELSE]
    <a href="#"><img src="{THUMB_ABS}" alt="{THUMB_NAME}" border="0" /></a>
[/ZOOM_ELSE]
<!--IMAGES_ENTRY_END//-->
 
 
<!--IMAGES_ENTRY_SPACER_START//--><!--IMAGES_ENTRY_SPACER_END//-->
 
 
<!--IMAGES_ROW_SPACER_START//--><!--IMAGES_ROW_SPACER_END//-->
 
 
<!--IMAGES_FOOTER_START//-->
  </div>
</div>
<a href="#" id="move_left_{ID}">&laquo; Left &laquo;</a> | <a href="#" id="move_right_{ID}">&raquo; Right &raquo;</a>
 
 
[PHP]
 
  $GLOBALS['block']['css']['slider_{ID}'] = 'specific/slider_new.css';
 
  $mootools_more = array( 'Fx/Fx.Scroll' );  // Loading more and FX.Scroll lib
  initJSPlugin($mootools_more, true);
 
  $GLOBALS['block']['custom_htmlhead']['slider_{ID}'] = '  <script type="text/javascript">
  <!--
  // 17.04.09 KH: enhanced and patched for mootools V1.2x
 
  window.addEvent(\'domready\', function(){
 
  Fx.Scroll.implement({
    scrollTo: function(y, x){
    return this.start(y, x);
    }
  });
 
    var slider_width  = 0;
    var step          = 106;
    var scroll_x      = 0;
    var slider_parent = $(\'slider_container_{ID}\').getSize().x;
 
    $$(\'div.slider a\').each( function(e) {
 
      slider_width += e.getSize().x + 5;
 
    });
 
    var scroll = new Fx.Scroll(\'slider_container_{ID}\', {
      wait: false,
      duration: 550,
      offset: {\'x\': 0, \'y\': 0},
      transition: Fx.Transitions.Quad.easeOut
    });
 
    scroll.scrollTo(0, 0);
 
    $(\'move_right_{ID}\').addEvent(\'click\', function(event) {
      event = new Event(event).stop();
      if(slider_width-slider_parent <= scroll_x) {
        scroll_x = scroll_x - 106;
      }
      scroll_x = scroll_x + 106;
      scroll.scrollTo(scroll_x, 0);
    });
 
    $(\'move_left_{ID}\').addEvent(\'click\', function(event) {
      event = new Event(event).stop();
      scroll_x = scroll_x - 106;
      if(scroll_x < 0) {
        scroll_x = 0;
      }
      scroll.scrollTo(scroll_x, 0);
    });
 
 
  });
 
  //-->
  </script>';
 
[/PHP]
<!--IMAGES_FOOTER_END//-->


CSS

/template/inc_css/specific/slider_new.css

/template/inc_css/specific/slider_new.css

div.slider {
   margin: 10px 0 10px 0;
   padding: 5px 0 5px 0;
   background-color: #888;
   overflow: hidden;
   width: 323px;
   position: relative;
   height: 146px;
}
 
div.slider .thumb_capture p {
   font-size: 9px;
   color: #444;
   background: #ddd;
   min-height: 25px;
 
}
 
div.slider div.inner {
   margin: 0;
   padding: 0;
   list-style: none;
   height: 146px;
   width: 700px;
   position: absolute;
   left: 0;
   top: 5px;
}
 
div.slider div.inner a {
   border: 3px solid #FFFFFF;
   padding: 0;
   float: left;
   background-color: #000000;
   margin: 0 0 0 5px;
}
div.slider div.inner a:hover {
   border: 3px solid #cfe9ff;
   text-decoration: none;
}
div.slider div.inner a img {
   width: 95px;
}


Erweiterte Variante

Siehe: Slider erweitert (Forum: http://forum.phpwcms.org/viewtopic.php?p=123104#p123104)

Vorteile:
- Breite, Höhe und Länge des Sliders richten sich nach den Einstellungen der Bildvorschaugrösse und Spaltenanzahl
- Bei mehreren Slidern auf einer Seite kann man nicht mehr über das Ende hinaus scrollen


deutsch/phpwcms-system/artikel/contentparts/bilder-spezial/slider.txt · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0