Jump to content

Comments (Core) + Reply feature


Recommended Posts

Dear PW-ers.

I would like to inform you that I’ve been in need of Tree View commenting system for a project being developed by me at the moment, thus, I’ve decided to make some additions to the commenting system developed by Ryan. Hereunder, I’d like to share the code with you for your kind information.
You can also practice it in case of need.
Some screenshots:


Download link: FieldtypeComments.zip

List of changed files:



small change in main.css:

.CommentForm_reply {


Archive updated.



  • Like 14
Link to comment
Share on other sites

+1 for integrating into main comments module as an option. Personally I prefer flat comments (as strange as it may sound, I find these easier to follow, since they're always in the order they've been posted) but I can think of many cases where nested comments would be preferred.

Great job @Khan!

  • Like 1
Link to comment
Share on other sites

Thanks @ryan, @biotech, @teppo.

@ryan, This is only addition for FieldtypeComments. 

If you have already installed FieldtypeComments you must run this SQL code:

ALTER TABLE field_comments
ADD COLUMN parent_id int unsigned NOT NULL default '0'

@teppo, ideas is not to be seems alike :)

Link to comment
Share on other sites

I think it should be an option for the core module.

Not that we're trying to compete against other systems in particular, but I know this is how it works for WordPress and on some sites works quite successfully: http://www.rockpapershotgun.com/2013/01/25/bit-by-bit-evoland-lets-you-play-through-gaming-history/#comments

Having it in there as an option and maybe enabled on your blog profile by default would be an idea ryan.

Link to comment
Share on other sites

It is also how things like Disqus work, so it will help those who want that sort of functionality without having to use a third party system.

In the Looooonggg term it might be nice to have just the one system, but be able to switch the display - either from the admin or by the user (or both)

Link to comment
Share on other sites

one of users asked me how to do counting comments with reply. 

for countuin comments with reply do next steps:

open /wire/core/FieldtypeMulti.php file and find this

136 line : if (!$this->page->is('admin')) $comment_list = $this->setTree($comment_list);

change it to:

$this->countWithReply = count($comment_list);

if (!$this->page->is('admin')) $comment_list = $this->setTree($comment_list);

then in this file add function:

public function countWithReply($event) {

    $event->return = $this->countWithReply;


then in this file add function:

public function init() {

    $this->addHookAfter('Page::countWithReply', $this, 'countWithReply');


to print result in your template file type this:

echo $page->countWithReply();
  • Like 3
Link to comment
Share on other sites

  • 1 year later...

Hello Khan,

great - this is the feature i was looking for.

Little issue. I was replacing the existing files in the wire folder ( folder FieldtypeComments ) with yours.

i am running the sql code, because the fieldtypeComments were allready installed.

Now several reply-formulars appearing and a javascript - Error is thrown ( $(...) live is not a function ).

in the admin eyerthing works fine ( pw 2.4.2 )

Are there any troubles with other modules/javascripts or some mistakes for my part during installation?

Many Thanks


Link to comment
Share on other sites

@itsberni: sounds like you're using jQuery 1.9 (or newer) on your site, with .live() already removed. Backend is still using 1.8.3, which has .live() in place.

Possible solutions would be either updating the module JS (replace .live() with .on() and make any other related changes) or using an older version of jQuery in your site's frontend.

  • Like 1
Link to comment
Share on other sites


you´re right! Thanks for the advice!

For all jquery 2.11 - users...

Change line 101 in the CommentList.php to

$('body').on('click', '#close', function(){...});

and pay attention to the css-snippet which will wipe out the additional reply-formular  :-[


Link to comment
Share on other sites

  • 3 months later...

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

  • Create New...