A feature I needed for my site was to display the name of the author of a comment in the Recent Comments block.
The attached patch does the following:
- Allows the administrator to enabled author names in the Recent Comments block
- Adds an if-statement to the actual block, so in case the administrator does not want author names, the original SQL query is used (the original SQL query is more efficient as it doesn't have to do an left join against the user table).
Attached is a patch against release 5.1. Please note that this is my first Drupal patch; your feedback is very welcome.
I tried to create a patch against CVS HEAD as well. However, the entire comments module is broken for me (the version that is in CVS now) so I can't verify if my changes work (or break the module even more).
At least 2 others Drupal users were looking for this functionality: http://drupal.org/node/93902, http://drupal.org/node/28887.
To see the patched module in action, here are some screenshots: http://www.guusbosman.nl/article/1729
| Comment | File | Size | Author |
|---|---|---|---|
| drupal51comments1.patch.txt | 4.86 KB | guusbosman |
Comments
Comment #1
ChrisKennedy commentedThis would indeed be a handy feature to have.
I think it would be more intuitive to have the default themed view be more like "<subject> by <user>", where subject links to the comment and user links to the user's profile. The current method of the username linking to the comment is poor usability imo.
There are quite a few errors in coding style in this patch. If/else braces, database table braces (e.g. "users" table), string concatenation spacing, and capitalization+periods for the inline comments (unless they're really short).
It seems like the time should remain on its own line just like the no-author version. The more compact display you suggest is something that the admin should implement as a custom theming function imo.
variable_get('anonymous', t('Anonymous')) should be used to display the anonymous username, as it's a configurable setting.
Comment #2
mdupontOld and irrelevant now that D8 is in development. Closing.