| Shurbann Martes
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Friday 02 January 2004 11:05:08 am 
                                                                
                                                                 Im trying to make all the comments to shwo up in the frontpage of my site: 
- The idea is to show them sorted by published date.- The name of the news of wich the comment is made is shown.
 - If there is a news with more then 1 comment, it will show only one, the most recent comment.
 
This is the code:{let comment_parent_array=array(0) comment_list=fetch(content,list,hash(parent_node_id,2,limit,6,depth,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array('comment')))}
 {section name=Comment loop=$comment_list}
 {section show=not($comment_parent_array|contains($Comment:item.id)) comment_parent_array=$comment_parent_array|insert($Comment:item.id)}
 {node_view_gui view=line content_node=$Comment:item}
 {/section}
 {/section}
 {/let}
 
line_view_comment:{let ParentNode=fetch(content,node,hash(node_id,$node.parent_node_id))}
 <div class="small">{$node.object.published|datetime(custom,"%H:%i")} <a class="small" href={$ParentNode.url_alias|ezurl}>{$ParentNode.object.name|upfirst|shorten(20)}</a></div>
 
So 1 and 2 is accomplished but the last part I don't know how to do it.Do you have some ideas?
 -Shurbann | 
                                                
                                                                                                                                                        
                                                        | Marco Zinn
                                                                                                                             | Saturday 03 January 2004 4:14:10 am 
                                                                 Hi, 
well, i didn't completely understand the code:{let comment_parent_array=array(0) comment_list=fetch(content,list,hash(parent_node_id,2,limit,6,depth,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array('comment')))}
 {section name=Comment loop=$comment_list}
 {section show=not($comment_parent_array|contains($Comment:item.id)) comment_parent_array=$comment_parent_array|insert($Comment:item.id)}
 [..]
 What is $comment_parent_array used for? You want to store the IDs of the articles in the array and check, if and ID already exists?
 Nice idea :)
 
But you say, it does not work.First, I thought "use max=1 in the loop", so you will get only one comment. But you seem to fetch all commments with one single fetch.
 Then, maybe you should try something like this (pseudo-code ;) )
 Fetch all articles
 section loop=article
 fetch all comments, where the current article is parent node, sorted by date
 section loop=comments, max=1 show=comments
 print comment with parent node name
 /section
 /section
 This might work, but the drawback is, that you need LOTS of DB fetches. Marcohttp://www.hyperroad-design.com
 | 
                                                                                                    
                                                        | Shurbann Martes
                                                                                                                             | Saturday 03 January 2004 4:23:50 am 
                                                                 Ok Marco.... Thanks for the pseudo-code. I'm only going to put the last 8 comments more or less. So it means 8x more fetches :( 
Yeah the idea was to put the ID's of the articles in the parent_array and check if it already exist in the array and if this is the case don't show the comment.. . I think I have the well known problem with namesection. I have to print the array to see if it the array exist in that section.
 
But thanks for the idea. If I don't solve the problem above I will implement the code as you told me.Cheers!!
 -Shurbann |