« Moved! Three years »

Comment updates and stuff!

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

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. 


Share on FaceBook

Trackbacks

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

Post your comment

Sign in with Twitter

Comments

  • I have feet.

    Posted by Caitlin, 14/08/2012 12:39am (9 months ago)

  • Dit is zwei test

    Posted by ❃ Emil Blume ❃, 13/04/2011 8:28am (2 years ago)

  • Cheers!

    Posted by Radek, 15/02/2010 8:32am (3 years ago)

  • Dit is een test

    Posted by Tijs Schippers, 10/02/2010 11:11pm (3 years ago)

  • Mega Cool!

    Posted by Jeroen, 10/02/2010 2:52am (3 years ago)

  • Erg leuk!

    Posted by Frans, 10/02/2010 2:51am (3 years ago)

  • Nice!!

    Posted by Tijs, 10/02/2010 2:50am (3 years ago)

  • Fine. I'll add in an option.

    Posted by Simon, 07/12/2009 7:39am (3 years ago)

  • The name for posting you muppet. I wants yomcat!

    Posted by yomcat, 07/12/2009 5:53am (3 years ago)

  • Email notification now works. Just not for Twitter accounts.

    Posted by Simon, 07/12/2009 4:50am (3 years ago)

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