I explain: (I couldn’t get the proper english term for that)
Today we only way to refer other reply is using “quote”. This way we can’t make a thread like:
– Topic
– Reply 1
— Reply 2(child of reply 1)
— Reply 3(child of reply 2)
— Reply 4(child of reply 3)
– Reply 5 (no parent)
Is it clear, now?
That’s what I did:
sp-install.php: added a new column parent_id bigint(20) default NULL //parent_id is the a value of post_id
sp-topic-view-class.php: added the new column to the query
$spdb->fields = SFTOPICS.’.topic_id, ‘.SFTOPICS.’.forum_id, topic_name, topic_slug, topic_status, ‘.SFTOPICS.’.post_count, forum_slug, forum_status, forum_rss_private,
‘.SFPOSTS.’.post_id, ‘.spdb_zone_datetime(‘post_date’).’, ‘.SFPOSTS.’.user_id,
guest_name, guest_email, post_status, post_pinned, post_index, post_edit, poster_ip, post_content, parent_id’.$waitCheck;
parse the recordset to reorder replies (this must be rewritten to have a better performance)
$reply = array();
$child = array();
//split parent and childs
foreach ($records as $r) {
if((int)$r->parent_id>0){
$child[$r->parent_id]=$r;
}
else{
$orderarray[$r->post_id] = $r;
}
}
//reorder
if(count($child)>0){
$records=array();
foreach ($orderarray as $post_id=>$record) {
$records[]=$record;
if(isset($child[$post_id])){
$records[]=$child[$post_id];
//check if child has child
foreach ($child as $child_id=>$record) {
//print $record->parent_id.’ ‘.$child_id.'<BR>’;
if($record->parent_id==$child[$post_id]->post_id){
$records[]=$child[$child_id];
}
}
}
}
$child=array();
}
sp-form-post.php: added a new field that will be populated when user clicks on “quote” $out.= “<input type=’hidden’ name=’parentid’ id=’parentid’ value=” />n”;
sp-post.php: added a new key the to array $newpost $newpost[‘parentid’] = ”;
sp-forum.js: modified the spjQuotePost to add the postid value to the hidden field parentid
Now I have to modify the template to show the thread when viewing a topic.