« Moved! Three years »

Comment updates and stuff!

Posted by Simon Welsh | 6 December 2009 | Comments (13)

Comments now have an email field. At the moment this is only used to grab a gravatar to display with your comment, but will soon be expanded to allow you to receive email updates and stuff like that. I don't it's compulsory yet, though I should change that.

Quoting from the email I sent to ss-dev about this:

I am currently working on extending the PageComment functionality with SilverStripe. As I'm sure most of you are aware, it is rather limited at the moment. 

My extension works as a module (available from http://simon.geek.nz/comments.tar.gz), which will allow you to use the extra functionality I have currently made. To add them to a page type, there's two small edits you need to make: 
- Add "Comments" => "BlogComment" to your $has_many 
- Add: 
        function PageComments() { 
                $hasComments = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"PageComment\".\"ParentID\" = '". Convert::raw2sql($this->ID) . "'")->value(); 
                if(($this->data() && $this->data()->ProvideComments) || ($hasComments > 0 && PageCommentInterface::$show_comments_when_disabled)) { 
                        return new BlogCommentInterface($this, 'PageComments', $this->data()); 
                } else { 
                        if(isset($_REQUEST['executeForm']) && $_REQUEST['executeForm'] == 'PageComments.PostCommentForm') { 
                                echo "Comments have been disabled for this page"; 
                                die(); 
                        } 
                } 
        } 
to your Controller. 

By default, this will: 
- Add an email field to the form 
- Allow email notifications of replies 
- Name and email for logged in users is pre-populated and can't be changed 
- Avatars are displayed. Currently they are 32x32 pixels. The avatar is either grabbed from $member->Avatar() (if it exists and returns an Image) or a gravatar (see http://gravatar.com
- Logged in users are not required to fill in the spam protection forms. This will become an option in a later release. 

There is also support for Twitter OAuth. This requires you to set up your site as a Twitter app (at http://twitter.com/apps/new) then provide your customer key and secret by editing comments/_config.php. This support, so far, allows: 
- Pre-population of name and website 
- Twitter avatar to be used 
- Tweeting on posting a comment (see http://search.twitter.com/search?q=commented+source%3Aelephpanthaven for my testing of this) 
Currently, you can't subscribe to email notifications if you're signed in with Twitter. 

This is all working and can be seen at http://simon.geek.nz/comment-updates-and-stuff/ 

Todo: 
- Facebook and OpenID integration (similar to Twitter's) 
- Email notifications for Twitter logins 
- Replies to comments 
- Better control over the display (new at bottom, no pages, etc) 
- Things I have yet to think up. 

I will eventually figure out how to open the SVN repository for this as well. 

Trackbacks

Trackback URL: http://simon.geek.nz/Trackbacks/add/1179

Post your comment

Sign in with Twitter

Comments

  • What's wrong with the name? It's the name of my blog...

    Posted by Simon, 07/12/2009 3:18am (9 months ago)

  • Now there is also Twitter OAuth support! You can even tweet that you posted a comment :)

    Posted by Simon, 07/12/2009 2:52am (9 months ago)

  • Your OAuth needs a little work. Like better naming choices.

    Posted by Michael Welsh, 07/12/2009 2:52am (9 months ago)

RSS feed for comments on this page | RSS feed for all comments