Expression Engine channel entries with Twitter Bootstrap Carousel Not working

最后都变了- 提交于 2019-12-13 14:13:44

问题


Ok, so i'm having an issue implementing a basic Twitter bootstrap Carousel via ExpressionEngine's channel entries. I think it has to do with the fact that you must designate the first li tag as "active" for bootstrap to know which image is presented upon page load. But my code is as follows

<div id="myCarousel" class="carousel slide">
          <!-- Carousel items -->
          <div class="carousel-inner">

     {exp:channel:entries channel="work" dynamic="no"}
       <div class="item">
        <div class="workItem">
          <a href="{title_permalink='work/view'}">{project_image wrap="image"}</a>
          <a href="{title_permalink='work/view'}"><h3>{title}</h3></a>
        </div>
       </div>
     {/exp:channel:entries}

           </div>
          <!-- Carousel nav -->
          <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
          <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

So what seems to be happening is when the page loads no image shows up because i don't have an "active" class tagged since this code simply runs through all the 'projects' i've created in EE control panel using channel:entries. Because the scroll arrows do show up and when i click on them it jumps to the first image and then i can scroll through the project images.

Is there a way to activate the first project (or most recent) as class="active" so that it will be the default landing project. Any help on this would be much appreciated...or if there is a better / easier way to do things let me know

thanks a ton,


回答1:


You can use the {count} variable in {exp:channel:entries} to add the class to only the first item with a conditional:

{exp:channel:entries channel="work" dynamic="no"}
  <div class="item {if count == 1}active{/if}">
    [...]
  </div>
{/exp:channel:entries}


来源:https://stackoverflow.com/questions/12396184/expression-engine-channel-entries-with-twitter-bootstrap-carousel-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!