PHPCMS V9使用SQL调用图片模板中图片组,使用bootstrap图片轮播插件carousel

07. November 2016 PHP 0

{pc:get sql=”SELECT pictureurls FROM phpcms_picture_data where id = $id” start=”0″ num=”30″ return=”pictureurls” }
{loop $pictureurls $pic_k $r}
{php $a=string2array($r[pictureurls])}
{loop $a $pic_l $v}
<img src=”{$v[‘url’]}” longdesc=”{$v[‘url’]}” alt=”{$v[‘alt’]}” />
{/loop}
{/loop}
{/pc}//可循环输出图片模板中指定id文章中图片组。

若把图片放在Bootstrap JS图片轮播插件中,代码如下

<div id=”pic1″>
<div id=”carousel-example-generic” class=”carousel slide” data-ride=”carousel”>
<div class=”carousel-inner” role=”listbox”>
{pc:get sql=”SELECT pictureurls FROM phpcms_picture_data where id = 1″ start=”0″ num=”5″ return=”pictureurls” }
{loop $pictureurls $pic_k $r}
{php $a=string2array($r[pictureurls])}
{loop $a $pic_l $v}
<div class=”item”>
<img src=”{$v[‘url’]}” longdesc=”{$v[‘url’]}” alt=”{$v[‘alt’]}” />
</div>
{/loop}
{/loop}
{/pc}
</div>
<a class=”left carousel-control” href=”#carousel-example-generic” role=”button” data-slide=”prev”>
<span class=”glyphicon glyphicon-chevron-left”></span>
<span class=”sr-only”>Previous</span>
</a>
<a class=”right carousel-control” href=”#carousel-example-generic” role=”button” data-slide=”next”>
<span class=”glyphicon glyphicon-chevron-right”></span>
<span class=”sr-only”>Next</span>
</a>
</div>
</div>
<script type=”text/javascript”>
$(document).ready(function(){
$(“.item:first”).addClass(“active”);
})
</script>


Leave a Reply

Your email address will not be published. Required fields are marked *