Hi Hugo, I dont know bootstrap carousel, but in the view you are iterating
many times the main div "carousel-example-generic".
In your case you need iterate only the dinamic content of the carousel, and
the carousel content are divs.
See this example with my comments:
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<!-- If you have 3 fixed items, you can leave this-->
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<!-- Here is where you will perform the iteration of your three
elements {{for post in news:}} -->
<!-- if index == 0 output this line -->
<div class="active item"><img src="your dinamic content for active
element" alt="banner1" /></div>
<!-- else output this -->
<div class="item"><img src="your dinamic content" alt="banner2"
/></div>
<!-- end if else -->
<!-- end iteration -->
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel"
data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel"
data-slide="next">›</a>
</div>
hope I've helped with this example.
2013/8/7 Hugo Costa <[email protected]>
> Hello!
>
> I'm doing a website where I have a carousel in which should be the 3
> latest news, going to search for Title, Content and Date to the database
> but isn't working like I wanted.
>
> The code:
>
> *default.py*
>
> def index():
> """
> example action using the internationalization operator T and flash
> rendered by views/default/index.html or views/generic.html
>
> if you need a simple wiki simple replace the two lines below with:
> return auth.wiki()
> """
> if auth.user:
> response.flash = T('Welcome %s %s' % (auth.user.first_name,
> auth.user.last_name))
> else:
> response.flash = T('Welcome Visitor')
> news = db(db.posts).select(orderby=~db.posts.id, limitby=(0, 3))
> return dict(news=news)
>
> *index.html*
> *
> *
> {{for post in news:}}
> <div id="carousel-example-generic" class="carousel slide">
> <ol class="carousel-indicators">
> <li data-target="#carousel-example-captions" data-slide-to="0"
> class=""></li>
> <li data-target="#carousel-example-captions" data-slide-to="1"
> class=""></li>
> <li data-target="#carousel-example-captions" data-slide-to="2"
> class=""></li>
> </ol>
>
> <div class="carousel-inner">
> <div class="item active">
> <img data-src="holder.js/900x500/auto/#777:#777" alt="900x500"
> src="http://payload.cargocollective.com/1/0/221/2318/08-Poster-2_900.jpg">
> <div class="carousel-caption">
> <h3><a href="{{=URL(a='hugo', c='default', f='show', args=[
> post.id])}}" title="{{=post.title}}">{{=post.title}}</h3>
> <p class="text-center">{{=XML(markdown(post.post))}}</p>
> <p class="text-right">{{=post.created_on}}</p>
> </div>
> </div>
>
> </div>
>
> <!-- Controls -->
> <a class="left carousel-control" href="#carousel-example-generic"
> data-slide="prev">
> <span class="glyphicon glyphicon-chevron-left"></span>
> </a>
> <a class="right carousel-control" href="#carousel-example-generic"
> data-slide="next">
> <span class="glyphicon glyphicon-chevron-right"></span>
> </a>
> </div>
> {{pass}}
>
> If you guys could give me a hand on this I'd apreciate it :)
>
> Thanks,
>
> Hugo
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.