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.