Answers to comments

Answers to comments

Postby vurt on Fri Apr 22, 2005 8:56 am

The answer-link contains the id of the parent comment. How can I access this variable in the templates?

My idea is to preset the subject with something like "Re: subject of parent comment".

Is there a way to get the comments displayed like this:

comment
answer1
answer2
...
comment
...

*vurt
vurt
 
Posts: 45
Joined: Tue Mar 29, 2005 10:26 am
Location: Germany

Postby jondaley on Fri Apr 22, 2005 9:19 am

I don't know if anyone has done this - I didn't see it in any of the templates when I went through them a while back, but I had been thinking about this too.

I think you need nested for loops to go through the comments (like the template already does) but you need to keep track of the parent ids, and display (with indents) those comments that have the current comment as a parent, and print that.

Now that I think about it more - probably a plugin is a better way to do it, as the plugin could do a SQL query to get all child comments, and return back a nested array of comment ids, and then the template could just print them out, reading the array in order, with one loop, rather than nested loops.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Answers to comments

Postby phunkphorce on Fri Apr 22, 2005 10:23 am

vurt wrote:The answer-link contains the id of the parent comment. How can I access this variable in the templates?

My idea is to preset the subject with something like "Re: subject of parent comment".


yeah I think it's a good idea to provide something optional like this so I have already made the necesary changes to provide this in 1.1 8)

If you'd like to have this feature in plog 1.0, follow these steps:

1) get this file and save it to the class/action/ folder: http://www.lifetype.net/svn/plog/plog/ ... .class.php
2) add a new string to the locale file called "reply_subject". This string will be used as the prefix in the subject of the reply comment:

Code: Select all
$messages["reply_subject"] = "Re: ";


3) in commentform.template, use the {$topic} variable wherever you would like the comment topic to appear:

Code: Select all
{$locale->pr("comment_topic")}<br/><input type="text" name="commentTopic" value="{$topic}"/><br/>
...


This feature will also be included in plog 1.0.1 but we will not make it public because it requires changes to the templates and new locale strings. Our policy is to keep templates, plugins and strings table accross minor releases (1.0.x) but if you need this feature you can already use it now if you apply the changes above (well, the feature is already public as soon as we openly discuss it here :), but what I mean is that will not be enabled by default until next version)

Another comment that might be useful for you: there is also a new {$comment} object available from within commentform.template that represents the comment to which we're replying, whenever we are replying to a comment (if not, then the object will not exist) You could use this to potentially show the text of the comment to which we're replying in commentform.template if you wish, but don't forget to check for the existance of such object before attempting to use it!

Code: Select all
{if $comment}
<p>You are replying to comment with text:</p>
<p>{$comment->getText()}</p>
<p>Posted by user {$comment->getUserName()}</p>
{/if}
...


Hope you find this useful :)

Is there a way to get the comments displayed like this:

comment
answer1
answer2
...
comment
...


Sometime ago I looked into this and a plugin seemed the wisest way. The problem is that generating a tree-like structure of data coming from the db is a bit resource-consuming, as it entails a few too many loops jus to build the tree, plus a few more to display it.

If somebody has a better idea about how to implement this, let me know.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby Monjo on Fri Apr 22, 2005 10:37 am

I will look around and see if other blogs support as default. For now I have found a WordPress plugin that does this.

http://meidell.dk/archives/2004/09/04/nested-comments/
http://meidell.dk/files/briansthreadedcomments15.zip
Monjo
Lifetype Expert
 
Posts: 344
Joined: Fri Oct 08, 2004 6:00 am
LifeType Version: not yet

Postby phunkphorce on Fri Apr 22, 2005 11:12 am

I will take a look at this plugin, but if only wordpress plugins were a bit easier to look at... this mess of logic and presentation code is really impossible to follow :(
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby phunkphorce on Fri Apr 22, 2005 11:42 am

btw, there was a stupid bug... the id of the parent comment wasn't being properly saved to the db so this information was lost in all comments. If interested, get the file linked above again, I've just fixed it.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby phunkphorce on Sun Apr 24, 2005 1:10 pm

nested comments:

http://www.lifetype.net/blog.php/plog_ ... mments.zip

unzip the file in your plugins/ folder and off you go. See the instructions in the "plugin centre" once the plugin has been detected.

The code is quite unefficient but it works... If somebody feels like improving it, be my guest :)
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby phunkphorce on Mon Apr 25, 2005 8:21 am

anybody tried the plugin yet? :roll:

I'd like to know if it works well enough so that we can make it available via sf.net...
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby Guest on Wed Apr 27, 2005 4:15 am

it work!
but displayed like this:

comment1
-----------------------
comment1_reply1
-----------------------
comment1_reply2
-----------------------
comment1_reply3
-----------------------
....
-----------------------
comment2
-----------------------
comment2_reply1
-----------------------
comment2_reply2
-----------------------
comment3



could i get the comments displayed like this:

comment1
comment1_reply1
comment1_reply2
comment1_reply3
.......
---------------------
comment2
comment2_reply1
comment2_reply2
---------------------
comment3


thanks
Guest
 

Postby phunkphorce on Wed Apr 27, 2005 4:19 am

it's a matter of using some CSS and perhaps some smarty logic. It shoulnd't be too difficult.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby Guest on Wed Apr 27, 2005 6:35 am

smileys plugin can't work......what should i do?
Guest
 

Postby vurt on Wed Apr 27, 2005 6:59 am

Anonymous wrote:smileys plugin can't work......what should i do?


after installing the nested comments plugin? Can't confirm. Works fine here. Have you enabled the plugin in the control-center?

*vurt
vurt
 
Posts: 45
Joined: Tue Mar 29, 2005 10:26 am
Location: Germany

Postby Guest on Wed Apr 27, 2005 7:38 am

>>after installing the nested comments plugin?
yes :D

>>you enabled the plugin in the control-center?
yes :D

if i delete this code
Code: Select all
{assign var=comments value=$nestedcomments->getNestedComments($post)}


then smileys plugin can work.
Guest
 

Postby phunkphorce on Wed Apr 27, 2005 7:47 am

the problem is that the smileys plugin is "hooked" to an event that the plugin does not throw when loading the posts. It shoulnd't be too difficult to modify the plugin to do that, I will take a look at it as soon as I can.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby Guest on Wed Apr 27, 2005 1:57 pm

edit your templates/xx/postandcomments.template file
Code: Select all
{assign var=comments value=$nestedcomments->getNestedComments($post)}
{foreach name=comment from=$comments item=comment}
<a name="#{$comment->getId()}"></a>
<div class="comment_outline_{$comment->getValue("depth")}">
<div class="comment_title_{$comment->getValue("depth")}"><div class="comments-head">[{$smarty.foreach.comment.iteration}] {$comment->getTopic()}</div></div>
<div class="comment_content_space">
{if $comment->getParentId() == 0}<div class="comments_post_{$comment->getValue("depth")}">
    [ <a href="{$url->postPermalink($post)}#comments_form">{$locale->tr("comments")}</a> | <a href="{$url->replyCommentLink($post,$comment)}">{$locale->tr("reply")}</a> ]
</div>{/if}
    {$comment->getText()}

<div class="comments_post_{$comment->getValue("depth")}">
    {assign var=commentDate value=$comment->getDateObject()}
    {$locale->formatDate($commentDate, "%Y-%m-%d %H:%M")} by
    {if $comment->getUserUrl() != ""}
     <a href="{$comment->getUserUrl()}"}>{$comment->getUsername()}</a>
    {else}
     {$comment->getUsername()}
    {/if}
</div>
</div>
</div>
<br />
{/foreach}


edit CSS file used by your template set
Code: Select all
/* comments */
div.comment_outline_1 {
   width: 100%;
   background-color: #696969;
   padding:2px;
   border-bottom: 2px solid #DDDDDD;
   border-right: 2px solid #DDDDDD;
}

div.comment_title_1 {
   font-size: 16px;
   background-color: #696969;
   height:20px;
   line-height: 140%;
   color: #FFFFFF;
   padding-top:1px;
   padding-left: 5px
}

.comments_post_1 {
font-family:verdana, arial, sans-serif;
text-align: right;
color:#666;
font-size:12px;
font-weight:normal;
background: transparent;
}

div.comment_outline_2 {
   width: 90%;
   margin-left: 10%;
   background-color: #C4C4C4;
   padding:2px;
   border-bottom: 2px solid #DDDDDD;
   border-right: 2px solid #DDDDDD;
}

div.comment_title_2 {
   font-size: 16px;
   background-color: #C4C4C4;
   height:20px;
   line-height: 140%;
   color: #FFFFFF;
   padding-top:1px;
   padding-left: 5px
}

.comments_post_2 {
font-family:verdana, arial, sans-serif;
text-align: right;
color:#666;
font-size:12px;
font-weight:normal;
background: transparent;
}

.comment_content_space {   
   background: transparent url(images/bg_white.gif);
   background-color: #FFFFFF;
   color: #000000;
   padding:10px;
   padding-top: 2px;
   padding-bottom: 2px;
}


Done!
Guest
 

Next

Return to Templates

cron