Carlos, thanks for the reply.

What I want is to write a comment to the correct post. In the view I list
all the posts, I put an input in to comment this post. Oh what I want is
when the user replies to a post in the comment input is corretament
associated with your post.

thank you

Em 6 de março de 2012 08:40, Carlos Costa <yamandu.co...@gmail.com>escreveu:

> You will need to pass the post ID in the url or var or something.
> And I think you want to show comments related to the post not another
> posts.
>
> comments = db(db.comment.id=request.args(0)).select()
>
> Pass this to the view.
>
> 2012/3/6 Ale <alessandro.agu...@gmail.com>:
> > Good morning everyone. I am making a simple application, but I'm running
> > into some doubt. I wanted to do something like
> thefacebook posts .. Where I
> > have a site that I put a post, listed below are all posts with the option
> > to comment on them. So far so good .. But how to write the data's
> > comment in a post post correct? Attached I am sending the screen of my
> > application, I think it is easier to visualize
> > what I wanted. Transmission also Model / View / Controller. If you
> can help
> > me will be grateful.
> >
> > I'd have to get the id of the post via ajax?
> >
> > My model:
> >
> > Post = db.define_table('post',
> >     Field('title'),
> >     Field('post'),
> >     format="%(title)s"
> >     )
> >
> > Comment = db.define_table('comment',
> >     Field('post', 'reference post'),
> >     Field('comment')
> >     )
> >
> > My Controller
> >
> > def index():
> >     form = SQLFORM(Post,
> >                     formstyle="divs",
> >                     submit_button="Postar").process()
> >
> >     form2 = SQLFORM.factory(
> >                     Field('comment', requires=IS_NOT_EMPTY()),
> >                     formstyle="divs",
> >                     submit_button="Comentar")
> >     if form2.process().accepted:
> >         print request.vars
> >         print request.args
> >         response.flash = 'form accepted'
> >     elif form2.errors:
> >         response.flash = 'form has errors'
> >     else:
> >         response.flash = 'please fill out the form'
> >
> >
> >     posts = db().select(Post.ALL)
> >     return dict(form=form, form2=form2, posts=posts)
> >
> >
> > my view:
> >
> > <div class="post">
> >     {{=form.custom.begin}}
> >         <p>Title</p>
> >         {{=form.custom.widget.title}}
> >         <p>Post</p>
> >         {{=form.custom.widget.post}}
> >         {{=form.custom.submit}}
> >     {{=form.custom.end}}
> > </div>
> > <div class="posts">
> >     {{for post in posts:}}
> >         <li class="posts" id=post_{{=post.id}}>
> >             <p>{{=post.post}}</p>
> >             <p>{{=post.id}}
> >             <div class="comment">
> >                 {{=form2.custom.begin}}
> >                     {{=form2.custom.widget.comment}}
> >                     {{=form2.custom.submit}}
> >                 {{=form2.custom.end}}
> >             </div>
> >         </li>
> >     {{pass}}
> > </div>
>
>
>
> --
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>

Reply via email to