Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Would you accept a hack?
Avatar
Jose Roberto Gomes
Member
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2012 - 1:06 pm

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.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 11, 2012 - 5:48 pm

Can you tell me a little more? By all means paste the code here...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2012 - 8:49 pm

yeah, interested... not sure what child replies means... question

Avatar
Jose Roberto Gomes
Member
Free Members
sp_UserOfflineSmall Offline
Apr 12, 2012 - 8:29 am

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.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 12, 2012 - 9:13 am

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Jose Roberto Gomes
Member
Free Members
sp_UserOfflineSmall Offline
Apr 12, 2012 - 12:25 pm

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. 🙂

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 12, 2012 - 1:50 pm

Understood.
We may well look at this ourselves at some point.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626