用bootstrap建站时用到幻灯片切换模块,里面有个active(下面代码中的data-slide-to="0"),其余的按顺序递增(1,2),如果用dedecms就可以用autoindex来替代,如下图中的切换小圆点,点击不同的圆点会切换不同的banner图片
代码语言:javascript复制 <div class="carousel slide" id="carousel-420353">
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#carousel-420353">
</li>
<li data-slide-to="1" data-target="#carousel-420353">
</li>
<li data-slide-to="2" data-target="#carousel-420353">
</li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img alt="" src="*/default1.jpg" />
</div>
<div class="item">
<img alt="" src="*/default2.jpg" />
</div>
<div class="item">
<img alt="" src="*/default3.jpg" />
</div>
</div>
<a class="left carousel-control" href="#carousel-420353" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#carousel-420353" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
如果用上面的代码,要是更换活动时就得每次去修改代码,我们可以将活动设置为栏目文章进行调用,通过修改后的代码如下
代码语言:javascript复制 <div class="carousel slide" id="carousel-420353">
<ol class="carousel-indicators">
{dede:arclist row="1" typeid="3" flag='h' channelid='17'}
<li class="active" data-slide-to="0" data-target="#carousel-420353">
</li>
{/dede:arclist}
{dede:arclist row="3" typeid="3" noflag='h' channelid='17'}
<li data-slide-to="[field:global.autoindex/]" data-target="#carousel-420353">
</li>
{/dede:arclist}
</ol>
<div class="carousel-inner">
{dede:arclist row="1" typeid="3" flag='h' channelid='17'}
<div class="item active">
<img alt="[field:title /]" src="[field:picname /]" />
</div>
{/dede:arclist}
{dede:arclist row="3" typeid="3" noflag='h' channelid='17'}
<div class="item">
<img alt="[field:title /]" src="[field:picname /]" />
</div>
{/dede:arclist}
</div>
<a class="left carousel-control" href="#carousel-420353" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#carousel-420353" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
active我们用头条标签(h)进行定义,其余用noflag来设置,这样就可以比较完美的调用了,感兴趣的朋友可以试试,也欢迎和ytkah交流