Recent Topics

1 Sep 22, 2005 18:45    

I did this in v12 because I don't have a dawn installation that allows comments, but I think it'll work anyway. Don't be too surprised if it doesn't though. The idea is to allow a visitor to subscribe to comments on only one post. That way they can follow the comments on what they're into instead of comments across your entire blog. Oh I built this on rss2 but you can probably do all flavors if you're into it.

Basically 3 things have to happen. First you need to create a post-specific version of the comments feed maker. Copy xmlsrv/rss2.comments.php as xmlsrv/rss2.comments_p.php and make one teeny tiny change inside. Find:

	require dirname(__FILE__).'/../b2evocore/_blog_main.php' ;
	$CommentList = & new CommentList( $blog, "'comment'", $show_statuses, '',	'',	'DESC',	'',	20 );
	header("Content-type: application/xml");

Replace it with:

	require dirname(__FILE__).'/../b2evocore/_blog_main.php' ;
	$CommentList = & new CommentList( $blog, "'comment'", $show_statuses, $postID,	'',	'DESC',	'',	20 );
	header("Content-type: application/xml");

Next open b2evocore/_class_blog.php and find this:

			case 'comments_rss2_url':
				return $xmlsrv_url.'/rss2.comments.php?blog='.$this->ID;

Now add a new case for your new file:

			case 'comments_rss2_url':
				return $xmlsrv_url.'/rss2.comments.php?blog='.$this->ID;
			
			case 'comments_rss2_p_url':
				return $xmlsrv_url.'/rss2.comments_p.php?blog='.$this->ID;

Finally, you need to give something for your visitors to know they can get a feed for the comments on this post. Open either skins/_feedback.php or skins/yourskin/_feedback.php and add the following where you find it appropriate. I put it right after the trackback url bit, but whatever works for you is stylin'.

<p><a href="<?php $Blog->disp( 'comments_rss2_p_url', 'raw' ) ?>&amp;postID=<?php echo $Item->get('ID') ?>" title="it's a syndication thing...">Subscribe to comments on this post (RSS 2.0)</a></p>

Clearly this has to go in a post-specific part of your blog - not your sidebar - because otherwise there is no way to know what the post ID will be. I guess you could even put it in your _main.php file inside the post loop, but I was thinking of the comments page so that's where it is.

Okay cool. Have fun.

2 Sep 22, 2005 20:47

This is a good hack. I posted it on plugins.b2evolution.net and marked it as 0.9.x compatible. If anyone tests it with 9.1, then let me know and I'll change it. I tried copying my old xmlsrv folder to my new Dawn installation and none of the feeds worked. Makes me suspect that something about the feeds has changed in the new version.

3 Sep 22, 2005 20:59

Good point. I'll see if the specific area in question changed, but hopefully a dawn user will try this and let us know pro or con before I have to crack open files.

4 Sep 22, 2005 21:34

Ok the problem I'm having is the per-post feed seems still to be listing ALL comments (not just those for the current post). Any ideas?

Edit: Note the version of b2evo I'm using is b2evo v 0.9.0.11 (with all current rpc patches.

I've gone back over the three files I've edited and can't find the problem. The RSS url for the per post comments feed looks ok, e.g. "http://mrshiney.froppy.com/blog/xmlsrv/rss2.comments_p.php?blog=2&postID=297"
but all the comments are definitely in there.

Where do we ensure that only comments with comment_post_id matching $postID get added to CommentsList?

5 Sep 22, 2005 22:14

Hi! Just saw your post on the other thread and asked you to do what you've done here. I see you're using v11 so that might be important. You should think about upgrading to dawn, not that the upgrade will fix your issue. Heck for all I know the hack won't work in dawn.

Where was I?

Oh yeah. I see on your feedback page that you have the link to the comments_p version of the file, and I see where you are still getting all the comments. Did you do the minor change to the comments_p file? Where you change '' to $postID? The link on your permalink page includes the post ID, so I have to wonder if you've got the change in your new file.

6 Sep 22, 2005 22:23

EdB wrote:

Did you do the minor change to the comments_p file? Where you change '' to $postID? The link on your permalink page includes the post ID, so I have to wonder if you've got the change in your new file.

Ed, thanks for your help thus far. Bear with me. :) Anyway, I think I made the correct change but let's see...

The following is from my rss2.comments_p.php file.


    require dirname(__FILE__).'/../b2evocore/_blog_main.php' ;
    $CommentList = & new CommentList( $blog, "'comment'", $show_statuses, $postID,    '',    'DESC',    '',    20 );
    header("Content-type: application/xml");

What do you mean about the PostID showing up on my permalink page? Doesn't that indicate that I DID make the change?

7 Sep 22, 2005 22:49

What I was refering to was what I see when I do a mouseover on your "subscribe to the comments on this post" link. I get http://mrshiney.froppy.com/blog/xmlsrv/rss2.comments_p.php?blog=2&postID=297 which obviously include both the comments_p file and the postID parameter. That means so far so good, but obviously rss2.comments_p.php isn't restricting the feed to comments for the post specified.

Take a look at your b2evocore/_class_commentlist.php file and look for "function CommentList(". That is the actual function I took advantage of to make this hack work. That is why you replaced '' with $postID in your rss2.comments_p.php file. Follow me? Your new file is telling that function "dude - I got a specific post I want the comments for so hook me up". Anyway the bits in my v12 installation that told me "a-ha!" are as follows:

$p = '',															// Restrict to specific post

and

		if( !empty( $p ) )
		{	// Restrict to comments on selected post
			$this->request .= ") WHERE comment_post_ID = $p AND ";
		}
		elseif( $blog > 1 )


Does your v11 version of b2evocore/_class_commentlist.php have the same stuff in it? Effectively what I did was realize you could tell that function to only show comments for one post, and took advantage of that in the new xmlsrv file. I then called up the xmlsrv file with the hack in your _feedback.php file, but it all goes belly up if v11 didn't have that bit.

8 Sep 22, 2005 22:58

EdB wrote:

Does your v11 version of b2evocore/_class_commentlist.php have the same stuff in it? Effectively what I did was realize you could tell that function to only show comments for one post, and took advantage of that in the new xmlsrv file. I then called up the xmlsrv file with the hack in your _feedback.php file, but it all goes belly up if v11 didn't have that bit.

It looks like my version of the file has the bits you mentioned. If I am understanding this correctly, adding $PostID as we did to that xmsrv file should be restricting the comments by post. Yet it doesn't.

Weird!

9 Sep 22, 2005 23:11

Shouldn't this bit (in _class_commentlist) include comment_post_id?


		// Call parent constructor:
		parent::DataObjectList( $tablecomments, 'comment_', 'comment_ID' );

I.e. change it to:


		// Call parent constructor:
		parent::DataObjectList( $tablecomments, 'comment_', 'comment_ID', 'comment_post_id' );

Edit: Well, making the change does not fix the problem. :( (Doesn't break anything, apparently, either!)

10 Sep 22, 2005 23:29

The first code you posted is what my v12 installation has, so I gotta figure it works for v12 that way. I have a question that might not even matter, but when you edited your _class_comment file did you type in $postID or paste the whole thing from the forums? I'm looking at the tabs between parameters and how pasting into a forum then copying back out makes them be a bunch of spaces, and wondering if it's related.

Just for kicks, how about editing your _class_comment file and making all the parameters in that function call have only one space after each comma.

Can't hurt at this point!

Also, you really should be thinking about upgrading. Skip right past v12 and go with dawn (v0.0.1). I know I have to upgrade, but my hacks are so sloppy that it'll take me forever to get it done and have the blog I want.

11 Sep 23, 2005 00:57

Yeah I did copy/paste from the forums. I just went over that line (in xmlsrv/rss2.comments_p.php right?) and fixed it so there is only one space after each comma.

Unfortunately it still doesn't work. :(


    require dirname(__FILE__).'/../b2evocore/_blog_main.php' ;
    $CommentList = & new CommentList( $blog, "'comment'", $show_statuses, $postID, '', 'DESC', '', 20 );

Edit: Btw about upgrading... Like you I have I lot of sloppy hacks installed. I don't plan on upgrading anytime soon. :)

12 Jul 16, 2007 23:57

Hi!

How to do this in b2 1.10.x ?

Thanks


Form is loading...