Maybe I do not use the right expresion. I want that users can be able to
reply on comments and that this is shown in kind of a indented layout.
In the redidclone there is a self-referencing field, but there is no
implementation in terms of output. I was looking db().select().as_trees()
implementation, and I can get righ, but I have problem with nested layout
(I'm using Semantic UI).
def show(row,n=0):
return '<div class="comment"><div class="content"><div
class="metadata"><span class="date">'+row.created_on.strftime("%d. %m. %Y
ob %H:%M")+'</span></div><div class="text">'+row.comment+'</div><div
class="actions"></div></div></div>'+'<div
class="comments">'.join(show(c,n+1) for c in row.children)+'</div>'
### in model
db.define_table('comment',
Field('comment','text', label='Comment'),
Field('question_id','reference question', readable=False,
writable=False),
Field('parent_id','reference comment'),
auth.signature,
redesine=True
)
def comments():
db.comments.question_id.default = request.args(0)
form = SQLFORM(db.comment, _class='ui form').process()
form.custom.submit['_class'] = 'ui button'
comments =
db(db.comment.question_id==request.args(0)).select().as_trees()
result = ''
for c in comments:
result+='<div class="comments">'+show(c)+'</div>'
return dict(form=form,result=result)
On Wednesday, 1 April 2015 22:37:32 UTC+2, Massimo Di Pierro wrote:
>
> Not as I would do it today but this old app had threaded comments:
> https://github.com/mdipierro/web2py-appliances/tree/master/RedditClone
>
> On Wednesday, 1 April 2015 15:18:26 UTC-5, Najtsirk wrote:
>>
>> HI,
>>
>> I am searching for the best solution for threaded comments. Do anybody of
>> you have plugin or at least example of implementation?
>>
>> Best,
>> Kristjan
>>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.