Jump to content

PW 2.2 - Comments fieldtype improvements


Nico Knoll
 Share

Recommended Posts

Hi,

I read in the roadmap about "Comments fieldtype improvements". So are they finished already or are you still working on it? Because I have some suggestions:

  • Add a "website" field
  • Save name, e-mail and website in cookies and load them automatically in the comment form if they're existing
  • Execute comment saves before rendering a page because it's problematic if you want to show e.g. "5 comments"
  • Add a "$comment->avatar" working with gravatar (or is it already?)

/Nico

Link to comment
Share on other sites

Good feedback, thanks Nico. The comments module is kind of weak right now, so it needs some attention very soon. The long-term plan for the 'Comments fieldtype improvements' is to convert the comments system over to use pages instead. The goal with converting them to pages will be to make them really accessible and searchable from the API standpoint. It'll also mean that you'll have a 'comment' template that you can add whatever fields you want to.

However, we'll likely make improvements to the existing Comments fieldtype before this. In fact, I've already built a new ProcessComments module that adds a 'Comments' option to your admin top nav, and lets you manage comments separately from pages... just haven't committed it to the core source yet. I will take your suggestion to add a website field and keep track of the email/website in the user's session.

Execute comment saves before rendering a page because it's problematic if you want to show e.g. "5 comments"

Some of this is at the discretion of how you utilize it. I recommend doing your comments output generation and processing before you send any output. When a comment is added, make your page redirect back to itself to both prevent reload-duplicates and start with fresh DB-loaded data. This also ensures that the user will see their comment rather than a "thanks" message (great if you aren't using a moderation queue).

Add a "$comment->avatar" working with gravatar (or is it already?)

This is not already in place. I thought I saw this on your stadtpirat site? Do you know how to do it? I'll add it if you tell me how....

Link to comment
Share on other sites

Well using gravatar is really easy. You just need to generate the right url:

<?php

$email = "someone@somewhere.com";       // the commentators email
$default = "http://www.somewhere.com/homestar.jpg"
$size = 40;                    // a gravatar is always a square (hope you know what I mean)

$grav_url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;

?>

/Nico

Link to comment
Share on other sites

Thanks Nico, that is nice and simple. I think we'd also need to cache the avatars locally for some period of time, to avoid DOS'ing the gravatar servers. :) One page with a dozen comments would fire of a dozen requests to gravatar.com. Maybe that's okay? Are you aware of any rules or best practices in this regard?

Link to comment
Share on other sites

Thanks guys, this is good to know. I will definitely plan to implement in FieldtypeComments. On a related point, any idea how we can automatically identify the users info if they are logged into Twitter or Facebook? Obviously we won't be able to get their email, but perhaps we can get their Twitter/Facebook name and maybe gravatar hash automatically? I have no idea if it's possible, I really haven't played around with the APIs of these services at all. But seems like I've come across sites that were identifying me in this fashion (or I might have mistaken JS-based widgets originating from Twitter/Facebook).

Link to comment
Share on other sites

I guess this isn't needed, if we would save name, email and website in cookies so you would only have to insert in once and after this it's automatically in the field and could be changed but don't have to.

And think about the people with fake names on twitter and facebook...

Link to comment
Share on other sites

There's no getting around people using fake names, regardless of Twitter or Facebook. :) But at least we've got Akismet to provide some level of spam protection. I think remembering the user's info in a cookie is a good idea either way.

Link to comment
Share on other sites

Thanks guys, this is good to know. I will definitely plan to implement in FieldtypeComments. On a related point, any idea how we can automatically identify the users info if they are logged into Twitter or Facebook? Obviously we won't be able to get their email, but perhaps we can get their Twitter/Facebook name and maybe gravatar hash automatically? I have no idea if it's possible, I really haven't played around with the APIs of these services at all. But seems like I've come across sites that were identifying me in this fashion (or I might have mistaken JS-based widgets originating from Twitter/Facebook).

There are those social widgets that identify you automatically. But on top of those there are few sites that are "special partners" with facebook and can personlize without clicking anything or stuff like that. See: http://www.yelp.com/ (login facebook first, then click to yelp and wait few seconds). I am not sure if you need to be anymore "special partner" or is that instant login allowed for everybody...

Link to comment
Share on other sites

Ryan, maybe those sites where you see your name and profile photo are Facebook comments? it's similar to Disqus but will recognize when you are logged into Facebook. I do find it a little creepy, when I land on a new site and there's my name and photo next to the comment field, but I imagine it's a useful feature for most people. Whatever encourages real people to comment must be a good feature.

Speaking of Disqus, which I think is a good, simple solution if you don't want to develop and manage your own system - I just wanted to share this post by the designer Sacha Greif which shows you how to really customize the Discus comments to fit in with your own site. I never realized it was so easy :

http://blog.disqus.c...squs-in-a-flash

Link to comment
Share on other sites

But on top of those there are few sites that are "special partners" with facebook and can personlize without clicking anything or stuff like that. See: http://www.yelp.com/ (login facebook first, then click to yelp and wait few seconds). I am not sure if you need to be anymore "special partner" or is that instant login allowed for everybody...

I hate that thing. Every time I turn off 'instant personalization' (that's what it's called), they change something and I have to turn it off again. I hate it.

Link to comment
Share on other sites

I love the utility of solutions like Disqus. But I also think one of the reasons (for some) to have comments on your site is to have more indexable content for Google, etc. When people are posting comments, your site is generating it's own content, and Google is picking that up. When you use something like Disqus, IntenseDebate, or FaceBook widgets, your comments are JS-powered. When spiders index the page, they don't see those comments and they don't become part of that page's indexable content … they don't contribute to your search performance. As a result, I think JS-based solutions like this are good for function, but not for performance. I care a lot about the search accessibility of content in my sites and wouldn't consider using a JS-based comments solution in my own sites, except as a temporary solution. Though in fairness, I've been using IntenseDebate on my own site for years (put in before PW's comments modules existed), but have always viewed it as temporary solution. My site has been ready for a re-do for a few years. :)

Link to comment
Share on other sites

Good point, I completely forgot about the SEO benefits of site comments as content.

Thankfully I haven't noticed this 'instant personalization' yet. I just checked my Facebook privacy setting and it says

instant personalisation is not yet available for you.

Of course this will be turned on by default when it's available…

Link to comment
Share on other sites

I love the utility of solutions like Disqus. But I also think one of the reasons (for some) to have comments on your site is to have more indexable content for Google, etc. When people are posting comments, your site is generating it's own content, and Google is picking that up. When you use something like Disqus, IntenseDebate, or FaceBook widgets, your comments are JS-powered. When spiders index the page, they don't see those comments and they don't become part of that page's indexable content …

I actually tested this, since there are ways to have google index Ajax-content, so thought that they probably index Facebook comments too. And they actually do that. I went to popular music site here in Finland, opened one of their reviews (http://www.nrgm.fi/kritiikit/manna-shackles/) and took part of one facebook comment and searched for that: http://www.google.fi/search?ie=UTF-8&q=%22Joskus+1980-luvun+ensimm%C3%A4isell%C3%A4+puoliskolla%22 and it returned the page where I took the snippet from.

Then one more google search revealed that this is indeed pretty new addition: http://just-ask-kim.com/google-now-indexing-commenting-systems/

Link to comment
Share on other sites

That's great to hear Google can execute JS and index stuff from it. That's quite a technical feat, I'm impressed. I did some testing a couple days ago with Disqus and found Google wasn't indexing them. But it may just depend on the site, widget version, etc. But the fact that they CAN definitely changes my opinion about javascript-based comments. However, I still have to believe there are major advantages to staying in control of the markup and accessibility of your comments… but just not as many as before. Things are always changing for the better.

Link to comment
Share on other sites

Hi,

I read in the roadmap about "Comments fieldtype improvements". So are they finished already or are you still working on it? Because I have some suggestions:

  • Add a "website" field
  • Save name, e-mail and website in cookies and load them automatically in the comment form if they're existing
  • Execute comment saves before rendering a page because it's problematic if you want to show e.g. "5 comments"
  • Add a "$comment->avatar" working with gravatar (or is it already?)

/Nico

I was just about to ask how I could add a website field to my comment forms in 2.1... is it not yet (reasonably) possible then?

Link to comment
Share on other sites

  • 2 weeks later...

Improvement? Or just an issue with me!? :)

After a fresh install of PW 2.1 - fetching the upstream/dev,

When i add this...

/** added as per comment module docs (api) from pw's site **/
echo $page->comments->render();
echo $page->comments->renderForm();

to the 'basic-page' template, to make this...

include("./head.inc");

echo $page->body;

/** added as per comment module docs (api) from pw's site **/
echo $page->comments->render();
echo $page->comments->renderForm();

include("./foot.inc");

I get a nice little form but a massive 3 inch space in b/w the Your Name/Email and the textarea form area 'Comment'.

Like this...

post-413-0-24311400-1328823241_thumb.png

(gulp!)

I'm sure it's cuz i'm new to PW overall, but would *love* some input :).

Link to comment
Share on other sites

wortell, welcome to the forums.

That is just an css issue with demo site & comments that has been there since beginning. Don't remember exact fix there, but probably changing .CommentForm_text clear: both to clear: left. Or then adding float: left.

  • Like 1
Link to comment
Share on other sites

That is just an css issue with demo site & comments that has been there since beginning. Don't remember exact fix there, but probably changing .CommentForm_text clear: both to clear: left. Or then adding float: left.

NP! :) thanks. will try.

Link to comment
Share on other sites

Apeisa is right. Change this line:

	.CommentForm_text {
			clear: both;
	}

To this:

	.CommentForm_text {
			clear: left;
	}

I will update that in the basic profile (thought I had, but now see I didn't).

Thx... it's one of the things I've come to 'follow' and love - hence investigating further for my own works - about PW, is the support is 'solid!' Unlike *ahem!* other framework "Gods" to be, where the inconsistent, unprofessional, undocumented help is not only frustrating to deal with but in many cases non-existent.

All in all thanks so much, guys. It worked.

I've merged my 2.2 master 'fork'd' of P21 with the dev/ branch and hoping to help contribute :P.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...