10

So Drupal has a 'special' commenting system.

Comments are second-class citizens in Drupal compared to nodes...

But why did the core team not just create a default Content Type, Block and View for comments, and allow the site administrator add in a comment block as necessary? Just like the 'Article' and 'Basic Page' content types, which we can create blocks and views for. Why are comments so different?

  • 3
    You seem to be essentially asking "why are comments not nodes?" The answer is simply "because they're not supposed to do the same thing". Just like you wouldn't use a tractor to race in Grand Prix; it could theoretically be done, but it would be crazy to do so. Read this for some more general background on entity types v content types – Clive Dec 18 '14 at 9:02
  • 1
    That IS essentially what I am asking. Thanks for the link, it is relevant. I would have asked a better question if I knew the terminology. Thank you for your understanding. – dayuloli Dec 18 '14 at 9:04
  • 1
    No problem, I wasn't trying to insinuate your question wasn't a good one - far from it in fact, if you're new to Drupal these sorts of things can be very confusing. I just wanted to get straight to the point though, in the case of comments v nodes it's as straightforward as "different requirements, different entity types" – Clive Dec 18 '14 at 9:06
  • 1
    @dayuloli now you know the terminology, so you can edit and make it a better question! :) – Mołot Dec 18 '14 at 9:06
  • 2
    @dayuloli comment or integral part of question, whatever you wish, just avoid parts that look so separate, if possible :) – Mołot Dec 18 '14 at 9:59
8

To answer this, I first had to understand one thing: Entities are not nodes.

Entity Types are special groupings of fields.

Node is an entity type, which requires some fields, such as 'Title', 'Author' and 'Publish Date'.

Content Types are instances of Node which further define more fields. So a 'blog post' content type can have 'Hook', 'Introduction', 'Summary' and 'Related posts' fields, in addition to 'Title', 'Author' and 'Publish Date'.

Node is an entity type specialized for content. A comment is not designed to be a node because it is too different from a typical content. It's not necessary to have a 'Title', 'Author' or 'Publish Date' field in a comment. Because it is so different, it is created as another Entity type instead.

For more details, see this article on Drupal.

  • 1
    Nodes, comments, taxonomy terms, users, etc are all entity types. Some have bundles, some don't. A node type is technically a "bundle" from entity point of view. – AyeshK Dec 18 '14 at 9:54
  • 2
    No need to dig very deeply to find something explicit: drupal.org/node/1261744 – Djouuuuh Dec 18 '14 at 9:57
  • 2
    Technically all entity types have a bundle @AyeshK. If one isn't provided core uses an implicit one – Clive Dec 18 '14 at 9:59
  • 2
    Thanks @clive - I actually meant some entity types have different bundles and some don't. Flag, Node are entity types with multiple bundle support. User, taxonomy term, etc have only one bundle. Thanks again for the clarification. – AyeshK Dec 18 '14 at 10:02
0

In Drupal 8 nodes and comments (and custom blocks and user added menu links and users and taxonomy terms and...) are entities both. While in D7 an entity was indeed just for a bundle of fields -- I still remember when they were simply $object and there was no API at all. In Drupal 8 entities have a proper CRUD API; they are classed objects with save, load etc. And comment settings are now a field so everything fieldable is commentable. The mind boggles at the possibilities (commented comments? Commentception! even that is possible AFAIK).

0

Just as a sidenote, sometimes perhaps you really do not need the power of the core Comments entity, but just a simple list of comments or notes (without replies) associated to the Content Type or Entity.

In these cases, you may lighten your system load disabling the Comments for that Content Type, and using just a field for storing the comments or notes.

At least 2 contrib modules provide this kind of field:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.