Jump to content

Additional input field for URL in comment form


Michael van Laar
 Share

Recommended Posts

By the way, being able to extend the comment form would be nice anyway. A typical use case would be an additional checkbox which a commenter can check to subscribe for a newsletter. You would then “only” have to hook into comment processing to pass this information (in combination with his e-mail address) through to an e-mail marketing service provider’s API.

But this is just an idea.

Link to comment
Share on other sites

You can currently do this by modifying or extending the CommentForm class. Copy /wire/modules/Fieldtype/FieldtypeComments/CommentForm.php to your own location, like in /site/templates/includes/ or something like that. Then rename the class to be something else, like "CommentFormMichael" or whatever you'd like it to be named. Modify the class to suit your needs. Then when you output your comments, use your class rather than the one that comes with PW:

echo $page->comments->render();
require("./includes/CommentFormMichael.php"); 
$form = new CommentFormMichael($page, $page->comments); 
echo $form->render();

This same approach can be taken with the comments list rendering too, except that you would copy or extend the CommentList class rather than the CommentForm class.

  • Like 2
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

×
×
  • Create New...