2013-10-22 3 views
0

Supersized Slideshow가 실행 중입니다. 슬라이드가 표시되면 새로 고침/새로 고침해야합니다. 사진은 내 서버에서 동적으로 가져오고 슬라이드 쇼가 재생되는 동안 새 사진을 추가 할 수 있습니다. 사진을 재생하고 새로 고침하여 새 사진을 확인할 수 있기를 바랍니다. 여기에 내가 사용하고있는 코드가있다jquery 슬라이드를 재생 한 후 페이지를 다시로드해야하는 번거 로움이 있습니다.

//php code to get pictures 

$picture = array(); 
    foreach($rows as $row) 
    { 
    $picture[] = $row["photo"]; 
    } 

    $newarray = array(); 
    for ($key_Number = 0; $key_Number < count($picture); $key_Number++) { 
    $newarray[] = "{image : '".$path . "/" . $album . "/" . $picture[$key_Number]."'}"; 

// Then in my Html 

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
<script type="text/javascript" src="js/jquery.easing.min.js"></script> 
<script type="text/javascript" src="js/supersized.3.2.7.min.js"></script> 
<script type="text/javascript" src="theme/supersized.shutter.min.js"></script> 

    <script type="text/javascript"> 

     jQuery(function($){ 

      $.supersized({ 

       // Functionality 
       slide_interval   : 4000,  // Length between transitions 
       transition    : 1,   // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left 
       transition_speed  : 700,  // Speed of transition 
       new_window    : 1,   // Image links open in new window/tab 
       performance    : 1,   // 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)           
       image_protect   : 1,   // Disables image dragging and right click with Javascript 

       // Components       
       slide_links    : 'blank', // Individual links for each slide (Options: false, 'num', 'name', 'blank') 
       slides     : [   // Slideshow Images 

              <?php echo implode(',', $newarray) ?> 
              ] 

      }); 
     }); 

    </script> 
    } 

나는 window.location.reload()를 사용하려고 생각했다. 또는 일부 기능을 구현하지만 그것을 구현하거나 작동시키는 방법을 모르겠습니다. 도와 주셔서 감사합니다.

답변

0

다음은 내가 찾은 해결책입니다. 해킹 조금하지만 아주 잘 작동합니다. 슬라이드 쇼의 길이를 세는 타이머 기능을 설정 한 다음 페이지를 새로 고침합니다. 내 슬라이드가 데이터베이스에서로드되기 때문에 PHP를 사용하여 길이를 계산했습니다. 당신이 하드 코딩 한 경우 사진이 그런

PHP

$count = $stmt->rowCount(); // counts how many pictures will be displayed 
$timer = $count * 4700; // slide length is 4000 and transition is 700 

내 초대형 기능에 ..... 당신은 이미 당신이 얼마나 많은 알고 있지만 페이지를 새로 고침 할 필요가 없습니다 것입니다 링크

<script type="text/javascript"> 

     jQuery(function($){ 
      var interval = 4000, 
      speed = 700, 
      slideArray = [<?php echo implode(',', $newarray) ?>]; // add your slides to this array 


      $.supersized({ 

       // Functionality 
       slide_interval   : interval,  // Length between transitions 
       transition    : 1,   // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left 
       transition_speed  : speed,  // Speed of transition 
       new_window    : 1,   // Image links open in new window/tab 
       performance    : 1,   // 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)           
       image_protect   : 1,   // Disables image dragging and right click with Javascript 
       stop_loop    : false,  // Pauses slideshow on last slide 
       // Components       
       slide_links    : 'blank', // Individual links for each slide (Options: false, 'num', 'name', 'blank') 
       slides     : slideArray  

      }); 

     }); 
    </script> 


// here is where we reload the page 
// I pass the information needed to pull the pictures from the database 
// and in my php I check for a $_GET['email'] etc, etc, etc. to start the 
// process over. It then finds new pictures, counts them, displays them. 
// Hopefully this will help someone else 

     <script> 
      setTimeout(function() { 
        <?php echo 'window.location.href = "http://www.myurl.com/slideshow/slideshow.php?email='.urlencode($email).'&album='.urlencode($album).'&directory='.urlencode($directory).'&dir2='.urlencode($dir2).'"'; ?> 

      },<?php echo $timer; ?>); 
     </script> 
관련 문제