Support Forum
Hello guys,
First of all, Simplepress is amazing, but I moving a tailor-made forum system into Simplepress and one thing we missed in SP was the child replies.
I've made a couple of changes and was successfull to have child replies. Would you accept that changes and set them as part of simple-press. Maybe, this would help a lot of people and the changes I made don't compromise the rest of the system.
To be more precise, I added lines in 6 files of simplepress core.
yeah, interested... not sure what child replies means...
Visit Cruise Talk Central and Mr Papa's World
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.
Interesting notion but I think you are going to have major problems with paging when one of your 'child' threads spreads over a page boundary. I think there might be a few other 'gotchas' to be discovered as well.
I would suggest looking at the sp_build_post_index() function where you could set the post_index column to order the entire topic as you want it and then change the sql that populates the page (by page) to order by post_index instead of post_id. That way there would be no post processing and page boundaries would be respected.
But am most interested in what you are trying to do and would like to see the final display when it is finished.
YELLOW
SWORDFISH
|
You are right, bugs will appear. First we will see how users behave, if they make big threads or everyone is going to reply to the main topic.
I will check sp_build_post_index(), your idea is excelent, I will check it.
Sure, I will show you the final result.
I just had to go thru this hack because of our old system, it has this feature and users always complain when you take something out. 🙂