Jump to content

PW 2.2 - Comments fieldtype improvements


Nico Knoll
 Share

Recommended Posts

Not sure if this is the right location for this question but when I place a comment, into the comment box, it simply shows a "Thanks for the comment..." on that page refresh, without the latest comment showing. Yet, it's in the database, cuz if I go to that page again (without doing a refresh - via GET), it's there clearly submitted and now showing.

-- is this the intended effect? just curious is there a setting to effect the 'message' being 'shown' on that next page refresh?

Plus, as a symptom of the above - when i didn't see it there initially, i hit the (f5) refresh and of course it resubmitted the form _POST, thus two entries.

-- this is the classic refresh issue... but...

Suggestion:

If there's not already a fix in place for this effect, to cover both issue above - that i'm clearly missing, could PW, after saving the comment, do an automatic _GET header-redirect (with or without an href.name tag associated), so as to not only:

-- show the comment, instant feedback to the user

-- minimize the comment from being submitted twice

(In addition - the form would be available as well, if the admin wanted it to be such, otherwise, if the person wants to enter another... etc... they have to hit the REFRESH (doh!) or if they're smart - to not duplicate, they'll go to the URL and force the _GET just to get the comment form again.)

Again, i'm sure i'm not the only one to uncover this, but confirming if this is possibly another area to help enhance? (putting it mildly as possible :P)

editting a few moments later...

I see this is somewhat touched on here:

http://processwire.com/talk/topic/905-comments-module-modification/page__hl__%2Bshow+%2Bcomment__fromsearch__1

Don't want to duplicate, i think my thoughts above are adding to this link thread above and i can move it there if you'd like, Ryan.

Edited by Bill
Link to comment
Share on other sites

Also...

is there also the ability to auto-js hide the form, and make it available via .js click toggle? (or ajax?)

just askin'

@Ryan - just boot me if there is a better spot to ask/deal with these issues, tho it seems this PW2.2 Comment thread seems sufficient for the time being. thanks again.

Link to comment
Share on other sites

We've got a queue of changes and improvements planned for the Comments module, and improvements in the area you've mentioned are part of it.

The comments output/processing comes in two parts, $page->comments->render(); and $page->comments->renderForm(); Usually you call renderForm(); after render(), which means that the comment form doesn't get processed until after the list of comments has already been rendered. Of course, you could reverse that and render the form first and then get your comment in the list. But that doesn't solve the double post issue, which we really need a redirect to do.

So the recommended way to handle it now is to $session->redirect('./'); after a comment is submitted. ProcessWire can't do this for you just because it doesn't know if you are calling upon it before or after you've started output (depending on the way you structure your templates). So it's playing safe by not attempting any redirects and instead lets you maintain control over how you want it to proceed.

// get comments before any output sent
$list = $page->comments->render(); 
$form = $page->comments->renderForm();

if($input->post->text && strpos($form, 'success')) {
   $session->redirect('./'); 
}

// ... later on when you are sending output
echo $list . $form;

More here:

http://processwire.com/api/fieldtypes/comments/

Also note the default behavior and markup created by the comments module was always intended as just an example. It's meant to be iterated and handled like pages are, where you make your own comment markup and form. But I usually go the easier route and just use the built-in 'example' output. :)

Link to comment
Share on other sites

is there also the ability to auto-js hide the form, and make it available via .js click toggle? (or ajax?)

Of course, but PW doesn't get involved in this stuff (it does no JS output on it's own for the front-end of your site). But you can add on whatever JS functionality you want to it.

Link to comment
Share on other sites

I like that feature too, but something we'll probably accomplish with an optional module that bolts on to it. Emails getting fired off every time someone responds to a comment could get out-of-hand on a large comment thread. So it's one of those things that really has to be built very carefully (which we can do).

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...