Did you see this slice? http://web2pyslices.com/main/slices/take_slice/90

2010/12/9 Andrew Evans <[email protected]>

> Hello I am wondering if there is a way to limit the posts on my blog main
> page to say 500 Characters and have a continue reading link from there on
> each post.
>
> This is my query it uses pagination :D
>
> *def index():
>     #Collect all posts in the db and use pagination
>     query = db.posts.id > 0
>     orderby = ~db.posts.id
>     pcache = (cache.ram, 15)
>     paginate = Pagination(db, query, orderby, display_count=5,
> cache=pcache, r=request, res=response)
>     # Now we get our subset.
>     rows=paginate.get_set(set_links=True)
>     return dict(rows=rows)*
>
> and my db tables :-)
>
> db.define_table('posts',
>     Field('userinfo', db.auth_user, default=auth.user_id, readable=False,
> writable=False,unique=True),
>     Field('category',db.category, requires=IS_IN_DB(db,db.category.id
> ,'%(name)s')),
>
> Field('created_on','datetime',default=datetime.datetime.today(),writable=False,readable=False),
>     Field('post_title', length=100, comment='Title of your post',
> requires=IS_NOT_EMPTY()),
>     Field('post_body', 'text', requires=IS_NOT_EMPTY()),
>     Field('image','upload', label='Image', comment='(Max Size) 600px by
> 600px', autodelete=True, requires=IS_IMAGE(extensions=('png', 'gif', 'jpg'),
> maxsize=(600, 600))))
>
> Thank you for any advice :-)
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio

Reply via email to