eZ Comments vs. comments via eZ content model

Wednesday 23 March 2011 10:10:31 am

By : Marko Žmak

The eZ Comments extension is a very simple and easy to use solution if you want to setup an article commenting system quickly. But in my experience it's a bad idea to use it if you need any advanced commenting functionalities. So read further if you want to find about it...

In my experience as an eZP developer I have implemented many sites with the article commenting feature. Only one of them was implemented using the eZ Comments extension, and soon after that I abandoned this approach and went back to implementing the comments system using the eZP's content model (objects of class “Comment” as children of articles).

Actually, my experience with both solutions taught me that the main problem of eZ Comments extension is that it doesn't use the eZP content model. Several usability and conceptual problems come out of this fact:

  • you can only delete on comment at the time – so imagine you have to delete 50 comments for one article
  • it only supports plain text comments, there's no rich text editing, no attaching files or similar functionality
  • you cannot have “threaded” comments (comments on comments)
  • you cannot create a fine grained roles and policies system for comments
  • you cannot “like” a comment or vote for it
  • users cannot report a inappropriate comment
  • you cannot have a list of all the comments of the site in one place

On the other hand... First, all of these features can be implemented using the Comment class for comments. Second, there are no features of eZ Comments extension that cannot be implemented using the standard eZP content model and functionalities.

Furthermore, one feature that is pointed out as most important in eZ Comments is:

“using separate table for storing comments to improve performance”

Which sounds like a very good idea but actually it isn't. Here are some counter arguments...

1) Does it really?

The statement that putting comments in a separate table gives a valuable performance improvement doesn't really stand. Anyone that have analyzed eZP fetches deeply (I mean like on the level of MySQL EXPLAIN query) and on real usage examples will know that when fetching only objects of Article class the performance is not really much degraded by the number of comment objects on your site. The article/comment ratio is usually evenly distributed over the node tree (you won't have a category with only 10 articles and 1000 comments) with a constant order of magnitude, which is usually very low. It won't make much difference if you perform an sql query on 1000 indexed objects or 2000.

Also, there are several techniques that can allow you to have a lot of content without loosing much of performance in fecthes. For example, I have a (high traffic) site with more than 200.000 objects performing complex fetches, and their performance is pretty much the same as if there were only 2.000 objects. On the site the comments are implemented using the “Comment” class and it does not degrade performance at all.

It's all about understanding your site and using eZP wisely.

2) Comments are not content?

Who when and why made the decision that comments are not content?

As far as I'm concerned, comments are content because I want to be able to do with them most of the tasks I want to do with other content:

  • be able to search for text through comments (think of eZFind)
  • be able to move them, hide/show, delete and restore them from thrash
  • fetch comments based on different criteria
  • sort the fetched comments based on different criteria
  • attach edit handlers and workflows to the comment publishing event
  • import/export comments using the same functions/extensions I use for other content
  • insert link to a specific comment or embed a comment in a text of an article

By putting comments in a separate database table you loose all this capabilities and also any other future functionality that will be implemented in eZP and it's content model.

To conclude...

My opinion is that the approach of implementing the comments system without using the powerful eZ content model was a bad decision and very wrong. It looks like reinventing the wheel in a shape of triangle...

The only true advantage that I found in eZ Comments it's that comes with ready made templates and allows you to setup the commenting system very quickly. But that can all be done reagardless of the implementation, right?

My suggestion would be to rewrite completely the eZ Comments extension and implement it using the eZ content model and existing eZP capabilities. And wrap it nice with all the shiny and easy to use features that already has, so that retains the same usability.

There it is. Now after I've written about comments, I'm ready to hear some comments...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 17 2025 23:53:33
Script start
Timing: Jan 17 2025 23:53:33
Module start 'layout'
Timing: Jan 17 2025 23:53:33
Module start 'content'
Timing: Jan 17 2025 23:53:33
Module end 'content'
Timing: Jan 17 2025 23:53:33
Script end

Main resources:

Total runtime0.0920 sec
Peak memory usage6,144.0000 KB
Database Queries42

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 588.0469152.6406
Module start 'layout' 0.00790.0029 740.687539.4844
Module start 'content' 0.01080.0798 780.1719379.1484
Module end 'content' 0.09060.0014 1,159.320319.7031
Script end 0.0920  1,179.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00343.6796150.0002
Check MTime0.00131.3696150.0001
Mysql Total
Database connection0.00080.882510.0008
Mysqli_queries0.031233.9092420.0007
Looping result0.00030.3578400.0000
Template Total0.055460.220.0277
Template load0.00192.091020.0010
Template processing0.053558.118220.0267
Template load and register function0.00010.093510.0001
states
state_id_array0.00060.695710.0006
state_identifier_array0.00111.220420.0006
Override
Cache load0.00171.8054430.0000
Sytem overhead
Fetch class attribute name0.00262.780730.0009
class_abstraction
Instantiating content class attribute0.00000.016630.0000
General
dbfile0.00212.2607100.0002
String conversion0.00000.011140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplblog_entry/full.tplextension/community_design/design/suncana/override/templates/blog_entry/full.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
2content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
3content/datatype/view/ezxmltags/header.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/header.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezkeyword.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezkeyword.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs