1Danke
ERLEDIGT
NEIN
NEIN
ANTWORTEN
3
3
ZUGRIFFE
219
219
EMPFEHLEN
-
10.11.11 09:29 #1
- Registriert seit
- May 2008
- Ort
- Baunatal (Hessen)
- Beiträge
- 413
Hallo,
ich habe überhaupt nichts mit javascript am Hut, deswegen wäre ich dankbar, wenn mir jemand hier hilft. Unzwar benutze ich ein fertiges js Skript für eine Slideshow, sowie PHP und Joomla.
Problem: welche Variable sagt mir ob gerade image1,2,3 oder 4 verwendet wird?
caption0,1,2 oder 3 soll je nachdem verwendet werden. (Need inline Assembler
)
MFGPHP-Code:<?php if ($this->countModules('position-2')) { ?>
<?php //bild name
$caption = $this->params->get('caption0');
?>
<div id="slide">
<div id="slideshow-w">
<div id="slideshow">
<img src="templates/<?php echo $this->template ?>/images/slide1.jpg" alt="image1" />
<img src="templates/<?php echo $this->template ?>/images/slide2.jpg" alt="image2" />
<img src="templates/<?php echo $this->template ?>/images/slide3.jpg" alt="image3" />
<img src="templates/<?php echo $this->template ?>/images/slide2.jpg" alt="image4" />
</div>
<div id="caption-image"><h4><?php echo $caption ?></h4></div>
</div>
</div>
<?php } ?>
<script type="text/javascript" charset="utf-8">
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j("#slideshow").slideshow({ pauseSeconds:5,
width: 744,
height: 273,
fadeSpeed: 0.5,
caption: false });
});
</script>Bei der Geburt ist ein Mensch so unfertig, wie ein an einem schönen blauen Montag in Taiwan hergestellter Computer vor der Programmierung.
- Wolfgang Körner
-
Gar keine. Das müsstest du über den visible-Selektor von jQuery abfragen können.
Im Übrigen kannst du den noConflict auch einfacher lösen, sodass du normal mit dem $ arbeiten kannst:
Code javascript:1 2 3 4 5
(function( $ ){ $(document).ready(function(){ //code }); })(jQuery);
Der Selektor sollte ungefähr so aussehen:
Code javascript:1
var activeImage = $('#slideshow img:visible').attr("alt");
Dies solltest du aber (evtl. mit einem kleinen Delay) direkt nach Bildwechsel feuern, also denke mal den Klick-Handler abfangen und dort activeImage setzen...
Genaueres kann man aber nicht sagen, weil keiner weiß, welche Slideshow du benutzt.Geändert von fpvz (10.11.11 um 09:41 Uhr)
-
10.11.11 10:03 #3
- Registriert seit
- May 2008
- Ort
- Baunatal (Hessen)
- Beiträge
- 413
Ok ich poste einfach mal schnell das Skript, welches ich benutze.
Problem zu deiner Vereinfachung: Ich erstellen Buttons zu den einzelnen Bildern. Wenn ich es so wie du mach, dann "hängen" die ne Sekunde oder so bis man das nächste Bild manuell anklicken kann.
PHP-Code:/**
* Slideshow Lite plugin for jQuery
*
* v0.5.3
*
* Copyright (c) 2009 Fred Wu
*
* Dual licensed under the MIT and GPL licenses:
* [url]http://www.opensource.org/licenses/mit-license.php[/url]
* [url]http://www.gnu.org/licenses/gpl.html[/url]
*/
/**
* Configuration options:
*
* pauseSeconds float number of seconds between each photo to be displayed
* fadeSpeed float number of seconds for the fading transition, the value should not exceed 'pauseSeconds'
* width integer width of the slideshow, in pixels
* height integer height of the slideshow, in pixels
* caption boolean display photo caption?
* cssClass string name of the CSS class, defaults to 'slideshowlite'
*/
(function($){
$.fn.slideshow = function(options){
var defaults = {
pauseSeconds: 5,
fadeSpeed: 0.5,
width: 854,
height: 354,
caption: true,
cssClass: 'slideshowlite'
};
var options = $.extend(defaults, options);
// ----------------------------------------
// slideshow objects and variables
// ----------------------------------------
var target = this;
var items = $(target).children("a");
var instance;
// ----------------------------------------
// some mandontory styling
// ----------------------------------------
if ( ! $(this).hasClass(options.cssClass)) $(this).addClass(options.cssClass);
$(this).css({
width: options.width + "px",
height: options.height + "px"
});
// ----------------------------------------
// create anchor links to make the structure simpler for manupilation
// ----------------------------------------
$(this).children("img").wrap(document.createElement("a"));
$(this).children("a").attr("target", "blank");
// ----------------------------------------
// add item sequence markups
// ----------------------------------------
var i = 1;
$(this).children("a").each(function(){
$(this).attr("rel", i++);
});
// ----------------------------------------
// create pagination and caption
// ----------------------------------------
$(this).append("<ul></ul>");
$(this).append("<ol></ol>");
var pagination = $(this).children("ul");
var caption = $(this).children("ol");
var i = 1;
var j = 0;
$(this).children("a").each(function(){
pagination.append("<li><a href=\"#\">" + i++ + "</a></li>");
caption.append("<li>" + $("#" + $(target).attr("id") + " img:nth(" + j++ + ")").attr("alt") + "</li>");
});
pagination.fadeTo(0, 1);
caption.fadeTo(0, 0.6);
caption.hide();
// ----------------------------------------
// shortcuts
// ----------------------------------------
var firstItem = $(target).children("a:first");
var lastItem = $(target).children("a:last");
var currentItem = firstItem;
// ----------------------------------------
// pagination highlight
// ----------------------------------------
var paginationHighlight = function(sequence){
pagination.children("li").children("a").removeClass("current");
pagination.children("li").children("a:nth(" + sequence + ")").addClass("current");
}
// ----------------------------------------
// caption
// ----------------------------------------
var showCaption = function(sequence){
caption.show();
caption.children("li").hide();
caption.children("li:nth(" + sequence + ")").fadeIn();
}
// ----------------------------------------
// slideshow logic
// ----------------------------------------
var makeSlideshow = function(){
// pagination click
pagination.children("li").children("a").click(function(){
if ( ! $(this).hasClass("current"))
{
// select the current item after the pagination click
currentItem = $(target).children("a:nth(" + ($(this).text()-1) + ")");
currentItem.show();
startSlideshow();
}
});
// pagination highlight
paginationHighlight(currentItem.attr("rel")-1);
// show caption
if (options.caption == true)
{
showCaption(currentItem.attr("rel")-1);
}
// show the current slide
currentItem.fadeIn(options.fadeSpeed*1000, function(){
$(target).children("a").hide();
$(this).show().css("z-index", 1);
});
// prepare for the next slide
// determines the next item (or we need to rewind to the first item?)
if (currentItem.children("img").attr("src") == lastItem.children("img").attr("src"))
{
currentItem = firstItem;
currentItem.css("z-index", 2);
}
else
{
currentItem = currentItem.next();
}
};
var startSlideshow = function(){
clearInterval(instance);
makeSlideshow();
instance = setInterval(makeSlideshow, options.pauseSeconds*1000);
};
// ----------------------------------------
// start the slideshow!
// ----------------------------------------
startSlideshow();
};
})(jQuery);
Geändert von 3Cyb3r (10.11.11 um 10:04 Uhr) Grund: Gibt wohl keine JavaScript Tags? Mit html Tags war auch fail^^
Bei der Geburt ist ein Mensch so unfertig, wie ein an einem schönen blauen Montag in Taiwan hergestellter Computer vor der Programmierung.
- Wolfgang Körner
-
10.11.11 10:31 #4
- Registriert seit
- May 2008
- Ort
- Baunatal (Hessen)
- Beiträge
- 413
Skriptsprachen sidn echt nichts für mich

Kannst du mir den Code evtl umschreiben das es funktioniert, danke. Ich hab wenig Zeit und bin auch verdammt müde -.-
PHP-Code:<?php/* $var activeImage = $('#slideshow img:visible').attr("alt");
switch ($var) {
case 'image1':
$caption = $this->params->get('caption0');
break;
case 'image2':
$caption = $this->params->get('caption1');
break;
case 'image3':
$caption = $this->params->get('caption2');
break;
default:
$caption = "unnamed";
break;
}*/
?>Bei der Geburt ist ein Mensch so unfertig, wie ein an einem schönen blauen Montag in Taiwan hergestellter Computer vor der Programmierung.
- Wolfgang Körner
Ähnliche Themen
-
Slideshow anhalten und weiterlaufen lassen
Von stella im Forum Flash PlattformAntworten: 2Letzter Beitrag: 25.10.09, 12:38 -
Slideshow - Bilder einfärben lassen
Von flashing_anna im Forum Flash PlattformAntworten: 9Letzter Beitrag: 17.02.09, 17:46 -
SlideShow nur ein mal Laufen lassen?
Von mogmog im Forum Flash PlattformAntworten: 1Letzter Beitrag: 16.01.06, 14:13 -
Bildnamen ausgeben
Von FLASHStyler im Forum Javascript & AjaxAntworten: 6Letzter Beitrag: 12.08.05, 01:23 -
Bildnamen in DB schreiben
Von tesarolle im Forum PHPAntworten: 3Letzter Beitrag: 13.05.05, 15:24





Zitieren
Login





