首先,这是用 smarty 编写的,所以请记住编码风格。这不是我的选择,但这是我被迫使用的。
我正在修改一个 nivo 横幅滑块以包含链接的可点击性。所以这就是问题所在。我需要将幻灯片变量从每张幻灯片传递到对话框。这里的目标是有一个对话框,这样我就可以让用户根据需要更新每张幻灯片的链接。页面如下所示: http: //griff4594.com/images/5-14-2013%209-05-41%20AM.png
这是代码:
{literal}
<script type="text/javascript" language="javascript">
function LinkUpload() {
var id = $(this).attr("rel");
$("#link-upload").dialog();
alert($id);
}
</script>
{/literal}
{if $slides}
<div class="ss_slides">
<ul class="ss_slides">
{foreach from=$slides item=slide}
<li id="slide_{$slide.slideid}">
<table class="ss_slides">
<tr>
<td class="ss_slides_image">
<img src="../slide-shows/{$slide.slideid}.{$slide.extention}" class="ss_thumb" />
<div class="ss_toolBox"><a href="#" class="ss_delete" SlideID="{$slide.slideid}" CTLID="#slide_{$slide.slideid}"><img src="uploadify/cancel.png" /></a></div>
</td>
</tr>
<tr>
<td>
<input type="hidden" id="{$slide.slideid}" rel="{$slide.slideid}" value="{$slide.slideid}"><button type="button" onclick="LinkUpload()">Slide Link {$slide.slideid}<$
</td>
</tr>
</table>
</li>
{/foreach}
</ul>
</div>
{foreach from=$slides item=v}
<div class="link-upload" title="Update Image Link" id="link-upload">
<p>Insert the link address you wish this Slide/Banner to link to when clicked.</p>
<form action="link_upload.php" method="POST">
Link: <input type="text" size="40" name="link" value="{$v.link}"><br />
<input type="submit" value="Update Link" name="update_link">
</form>
</div>
{/foreach}
{/if}
这是从变量 $slide 中提取的数组,因此您可以引用它:
Array (5)
0 => Array (6)
link => "http://google.com"
slideid => "2"
filename => "image235367.png"
extention => "PNG"
slideshowid => "1"
iorder => "3"
1 => Array (6)
link => "http://pvponline.com"
slideid => "5"
filename => "400x390px-LL-e49a9db0_2694-nooooooooo..."
extention => "JPEG"
slideshowid => "1"
iorder => "2"
2 => Array (6)
link => "http://etrade.com"
slideid => "6"
filename => "38783834021_large.jpg"
extention => "JPG"
slideshowid => "1"
iorder => "4"
3 => Array (6)
link => null
slideid => "7"
filename => "a.gif"
extention => "GIF"
slideshowid => "2"
iorder => "0"
4 => Array (6)
link => null
slideid => "8"
filename => "alpha.jpg"
extention => "JPG"
slideshowid => "2"
iorder => "0"
因此,现在弹出对话框并为我提供数据库中的 URL,但它们没有按 id 正确显示。这意味着他们不会出现单击的幻灯片,如下所示: http: //griff4594.com/images/5-14-2013%209-13-12%20AM.png
我想要的是,如果我单击幻灯片 1,我希望弹出一个对话框,其中包含它的链接。但现在它只是拉随机的。谁能指出我正确的方向?