WordPress.org

Forums

IP.Board Comments
Adding number of forum replies (11 posts)

  1. Beer
    Member
    Plugin Author

    Posted 3 years ago #

    I'll be looking at the code to see how to implement the number of forum replies. If I'm successful in doing so, I'll push a change to the repository.

    http://wordpress.org/extend/plugins/ipb-comments-for-wordpress/

  2. Punk Rock Geek
    Member
    Posted 3 years ago #

    This would be amazing. Thank you for all of your hard work!

  3. golgoth
    Member
    Posted 3 years ago #

    Hi there! any news about this feature and/or the development of this mod?

    thanks

  4. ludalex
    Member
    Posted 3 years ago #

    Shouldn't this be really easy with the XML-RPC Api?

    Anyway, any updates?

  5. ludalex
    Member
    Posted 3 years ago #

    I did it my myself:
    add these two functions to class.ipbcomments.php:

    function get_replies_number( $topic_id ) {
    
    		if ( ! (isset($this->options['ipb_field_path']) OR file_exists($this->options['ipb_field_path'])) ) {
    			return FALSE;
    		}
    
    		ini_set( 'display_errors', 0 );
    
    		// Keep the board from redirecting
    		// http://community.invisionpower.com/tracker/issue-26224-issues-with-ssiphp/
    		define('CCS_GATEWAY_CALLED',FALSE);
    
    		require_once( $this->options['ipb_field_path'] .'/initdata.php' );
    
    		require_once( IPS_ROOT_PATH .'sources/base/ipsController.php' );
    		require_once( IPS_ROOT_PATH .'sources/base/ipsRegistry.php' );
    
    		$registry = ipsRegistry::instance();
    		$registry->init();
    
    		// build the select statement, skip the original post, we just want the replies
    		$registry->DB()->build( array( 'select' => 'posts',
    							'from'  => 'topics',
    							'where' => 'tid = ' . $topic_id
    							)
    						);
    
    		$result = $registry->DB()->execute();
    
    		 if ( $result ) {
    
    				$num = $registry->DB()->fetch();
    
    				return $num['posts'];	
    
    				}
    
    	}

    and:

    function get_topic_ID () {
    
    		$post_ID = get_the_ID();
    		$meta = get_post_meta($post_ID,'forum_topic_meta');
    		extract($meta[0]);
    
    		return $topic_id;
    
    	}

    And anywhere on your wordpress page, for example in comments.php, you can display how many replies has the topic corresponding to the post with this:

    $ipb_comments = new WP_IPBComments;
    	echo "topic id: ".$topicID = $ipb_comments->get_topic_ID();
    	echo "replies number: ". $ipb_comments->get_replies_number($topicID);
  6. golgoth
    Member
    Posted 3 years ago #

    Thanks a lot, but it doesn't work in my website (http://www.rpgitalia.net/ actually using WP 3.3): it gets the correct id and number of replies for the first two articles only, then i get a strange "www.rpgitalia.net Driver Error" message (instead of topic id) and the page stops from loading.

  7. ludalex
    Member
    Posted 3 years ago #

    golgoth, have you checked if the posts that give you the error got posted on the forum using IPB.Comments?
    That could be the problem.

  8. golgoth
    Member
    Posted 3 years ago #

    Oh yeah, now that you mention it that news is not in the forum. Is there a way to bypass that error not showing the number of comments?

  9. ludalex
    Member
    Posted 3 years ago #

    change get_topic_ID() in class.ipbcomments.php with this:

    function get_topic_ID () {
    
    		$post_ID = get_the_ID();
    		$meta = get_post_meta($post_ID,'forum_topic_meta');
    
    		if(!empty($meta)) {
    			extract($meta[0]);
    			return $topic_id;
    		} else {
    			return false;
    		}
    
    	}

    and in comments.php or whatever you want:

    $ipb_comments = new WP_IPBComments;
    	echo "wp post: ". get_the_ID() . "<br>";
    	$topicID = $ipb_comments->get_topic_ID();
    	if($topicID) {
    
    		echo "topic id:". $topicID;
    		echo "replies number: ". $ipb_comments->get_replies_number($topicID);
    
    	}
    	else {
    			echo "Forum post doesn't exist.";
    	}
  10. golgoth
    Member
    Posted 3 years ago #

    Perfect, thank you :)

    There are some news in my website which do not autopost into the forum because i manually write the "forum_topic_url" custom field during creation, since i want to link those news with already existing topics.

    Doing that way i noticed that forum_topic_meta doesn't contain neither the last comments nor the total replies: is there a way to make wordpress "recreate" that field after adding a custom forum url?

    Thanks again

  11. Exzina
    Member
    Posted 2 years ago #

    Hello. When someone reply wp post related topici i want show teh replyies under wp post, like wp comments. Do you any script can do this?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • IP.Board Comments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic