Now that comment is a fieldable entity type, it becomes possible to add fields to it, and end up with output such as illustrated below.

HTML generated for the comment body

The point is to show that the HTML generated for the comment body does not play well with the field output because it does not have a wrapping tag like each field instance has. In Drupal 6, div.content was playing that role, but now div.content can contain pretty much anything and is not representative of the comment body alone.

One immediate drawback of this messy output is that themers don't have a direct CSS class to target the comment body without styling all the fields attached to comment. Another problem is that the RDFa property attribute which is currently located on the "global" div.content is not placed correctly: it is meant to annotate the comment body alone, so it will also include any other field instance content which is attach to the comment. Secondly, it cancels out all RDFa information contained in the children tags, including the rdf-meta tag and all the potential field RDFa annotations. We need to be able to move property="content:encoded" to a tag that only contains the comment body. This was one of the goals of #538164: Comment body as field but it's stalled at the moment. We need to work on an alternative solution in case it does not get committed.

Comments

scor’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

starter patch. This patch generates the right HTML output inline with the requirements above. This is the kind of output we get:

<div class="content">
  <span class="rdf-meta" resource="/d7git/node/1" rel="sioc:reply_of"></span>
  <div class="comment-body" property="content:encoded">
    <p>Fusce ut sollicitudin eros. Nam elementum tempor nibh, vitae pretium enim porta id. Integer suscipit congue enim, ac tincidunt libero venenatis at.</p>
    <p>Praesent tempus; eros nec sagittis viverra, turpis nulla euismod enim, at tempus augue quam at odio?</p>
  </div>
  <div class="field field-name-taxonomy-tags field-type-taxonomy-term field-label-above clearfix">
    <p>random field content</p>
  </div>
  <div class="field field-name-taxonomy-tags field-type-taxonomy-term field-label-above clearfix">
    <p>random field content</p>
  </div>
  ... as many field as one wants ...
</div>

I think it would make sense to generalize the comment body wrapper to be in the comment module, and allow rdf.module to add its own RDFa attributes to it. But first I'd like to get some feedback on the general idea.

dries’s picture

Let me revisit #538164: Comment body as field first. Stay tuned.

Status: Needs review » Needs work
Issue tags: -RDF, -RDFa

The last submitted patch, , failed testing.

Status: Needs work » Needs review
Issue tags: +RDF, +RDFa

Re-test of from comment #2394168 was requested by @user.

dries’s picture

#538164: Comment body as field was committed to CVS HEAD so this patch is probably no longer necessary.

dries’s picture

Correction, that patch wasn't committed yet.

scor’s picture

Status: Needs review » Closed (duplicate)