我想知道是否有人能够帮我修复这个脚本...它基本上只是调用幻灯片,如果文件是图像,vimeo播放器,如果它有一个vimeo网址,和嵌入式swf,如果它是一个Flash文件。
<div id='jessslide'>
<?php
$photos=file("work.txt");
echo "<div id='slider-wrapper'>";
foreach($photos as $image){
$flag=0;
$item=explode("|",$image);
if($item[0]==$fields[0]){
$photo=trim($item[1]);
// check for Vimeo
if(strpos($photo, "vimeo.com") && $flag==0){
echo "<iframe src='$photo?title=0&byline=0&portrait=0' width='900' height='500' frameborder='0' webkitAllowFullScreen allowFullScreen></iframe>";
$flag=1;
}
// check for Flash
if(strpos($photo, ".swf") && $flag==0){
echo "<object id='myId' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='900' height='500'><param name='movie' value='$photo' />
<!--[if !IE]>-->
<object type='application/x-shockwave-flash' data='images/work/$photo' width='900' height='500'>
<!--<![endif]-->
<div>
<h1>Alternative content</h1>
<p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>";
$flag=1;
}
// If it's not Vimeo or Flash, then it must be a photo
if($flag==0){
echo "<div id='slider' class='nivoSlider'><img src='images/work/$photo' alt='' /></div>\n";
}
}
}
echo "</div>";
?>
</div>
一切正常,但幻灯片只显示1张图片。查看生成的源时,这是幻灯片显示的内容:
<div id='jessslide'>
<div id='slider-wrapper'><div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet1.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet2.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet3.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet4.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet5.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet6.jpg' alt='' /></div>
<div id='slider' class='nivoSlider'><img src='images/work/sparklingsweet7.jpg' alt='' /></div>
</div>
</div>
这就是正确的工作幻灯片输出应该是这样的:
<div id='slider-wrapper'>
<div id='slider' class='nivoSlider'>
<img src='images/work/sparklingsweet1.jpg' alt='' />
<img src='images/work/sparklingsweet2.jpg' alt='' />
<img src='images/work/sparklingsweet3.jpg' alt='' />
<img src='images/work/sparklingsweet4.jpg' alt='' />
<img src='images/work/sparklingsweet5.jpg' alt='' />
<img src='images/work/sparklingsweet6.jpg' alt='' />
<img src='images/work/sparklingsweet7.jpg' alt='' />
</div>
</div>
所以它似乎是一个div问题......我没有用php中的div做正确的事情。有人想要这个愚蠢的div问题,真是太棒了吗? :)
*我在php页面上的php脚本外面只有一个div,即“jessslide”。
答案 0 :(得分:1)
<div id='jessslide'>
<?php
$photos=file("work.txt");
foreach($photos as $image){
$flag=0;
$item=explode("|",$image);
if($item[0]==$fields[0]){
$photo=trim($item[1]);
// check for Vimeo
if(strpos($photo, "vimeo.com") && $flag==0):
echo "<iframe src='$photo?title=0&byline=0&portrait=0' width='900' height='500' frameborder='0' webkitAllowFullScreen allowFullScreen></iframe>";
$flag=1;
// check for Flash
elseif(strpos($photo, ".swf") && $flag==0):
echo "<object id='myId' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='900' height='500'><param name='movie' value='$photo' />
<!--[if !IE]>-->
<object type='application/x-shockwave-flash' data='images/work/$photo' width='900' height='500'>
<!--<![endif]-->
<div>
<h1>Alternative content</h1>
<p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>";
$flag=1;
// If it's not Vimeo or Flash, then it must be a photo
else :
$photoarray[] = $photo;
endif;
}
}
if (isset($photoarray)):
echo "<div id='slider-wrapper'><div id='slider' class='nivoSlider'>";
foreach ($photoarray as $photo):
echo "<img src='images/work/$photo' alt='' />\n";
endforeach;
echo "</div></div>";
endif;
?>
</div>
答案 1 :(得分:0)
我不完全确定你在做什么,但id是一个唯一的标识符。您不能在同一页面上具有相同ID的多个元素。我先看看那里是否是你问题的根源。很可能它正在做你想要的任何你想要的最后一个div的id为“slider”,其余的都只是以某种方式被破坏。