Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Rich snippets on Google or Yahoo! usually include the number of replies (or reviews) for a given post. I confirmed with Peter Mika (SearchMonkey architect) that this information must be on the page in order for it to be displayed in the search results (having it on the tracker page for example is not enough). Since Drupal does not explicitly display this in the HTML output, we can simply add this information as part of the RDFa metadata present in the
tag of the page.Comment | File | Size | Author |
---|---|---|---|
#10 | 632092_replies_rdfa_10.patch | 4.39 KB | scor |
#7 | 632092_replies_rdfa_7.patch | 4.39 KB | scor |
#3 | rdf-num_replies-632092-4.patch | 5.2 KB | linclark |
#1 | 632092_replies_rdfa.patch | 4.29 KB | scor |
Comments
Comment #1
scor CreditAttribution: scor commentedpatch with tests
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedshould check for access comments permission?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedChecks for 'access comments' permission.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #5
Dries CreditAttribution: Dries commentedCurious -- shouldn't the permission span all the code instead just the meta tag in the page header?
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentednext question. can this code live in a node_preprocess_node() instead of rdf_preprocess_node()?
Comment #7
scor CreditAttribution: scor commented@Dries: we test for
isset($variables['content']['links']['comment']['#links']['comment_comments'])
which returns false if the user does not have access to comments.@Moshe: do you mean template_preprocess_node()? I'm not opposed to it, and this remark could apply to more code in rdf_preprocess_node(). So far we've tried to keep the RDFa logic in rdf.module as much as possible but effulgentsia or sun mentioned it to the respective template function. At the end of the day you would still need to check whether the RDF module is enabled though. Would it bring much performance improvement?
The patch adds a line of documentation above number of comments annotation code.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedI said node_preprocess_node, not template_preprocess_node. but i see your point about checking for rdf module. i am ok with rdf_preprocess_node.
Comment #9
mlncn CreditAttribution: mlncn commented<meta about="/d7rdfa/node/1" property="sioc:num_replies" content="3" />
It looks beautiful, and it can count, too!
Comment #10
scor CreditAttribution: scor commentedrerolling patch.
Comment #11
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!
Comment #12
scor CreditAttribution: scor commentedThanks Dries, nice to see you looking at these RDF issues - keep the ball rolling, there are a few more looking for your attention including the beast #538164: Comment body as field ;)