use views to filter comments
aharown07 - March 10, 2009 - 01:35
| Project: | CCK comment reference |
| Version: | 6.x-1.1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
How about adding ability to use a View to limit available comments like Node Reference does? Problem I anticipate is impact on performance when I've imported some 20,000 comments.
(Apologies if this issue's already been turned in. Didn't see it in searches.)

#1
Sounds reasonable as request, I'll take a look how node reference does this somewhere next week. I'll keep you posted on the progress.
#2
Quick question, I've been looking at node reference and views and did a quick proof of concept on my local machine and there's really no big win in using a view to select comments. There are a few problems with views, the biggest being the fact that views doesn't give the ability to filter on NID if the base table is comments, you can't use exposed filters etc. so how about simply using the autocomplete feature that's built in comment reference? Or am I missing the point somewhere ?
#3
Well, the point was to make the comments available to the autocomplete more limited. For example, I was going to use this for a special node type "moderator note" and have my moderators create nodes to record misbehavior in forums. So the comment reference autocomplete would allow them to select the comment(s) involved.
Here's the problem: they only need to see comments for, say, the last thirty days in that autocomplete... and it actually makes selection of comments more difficult if comments three years old also appear in the autocomplete... and it seems like a list that long would be slower as well.
We average about 200 comments a day, I'm told (at our non-Drupal site).
It's not urgent. For now, I'm planning on implementing the "moderator notes" feature w/ordinary text field, and moderators can paste in URL's like they're used to. But a comment ref. field that is useful in our situation would be slick.
Not knowing much about the guts of the module (OK, knowing zero), maybe it would be easier to add an admin option to "limit comments to last 30 days" or something and skip Views. Works just as well for me.
#4
Having the limit to 30 days sounds more interesting to me to, less code and this way we don't have to use views (found some more annoying issues where I don't want to work around). I'll integrate that option this weekend and also adjust the results a bit so comments in the autocomplete (or select box) also show the data and are automatically ordered by date DESC.
#5
Super. Many thanks.
#6
Hi, I committed a new version a few seconds ago with some new features on the settings page:
- ability to limit to N days
- order by subject, newest or oldest
- select all, published or unpublished comments
A dev release is available at http://drupal.org/node/243311, it will be rebuilt within the next 12 hours or you can checkout from cvs too of course (http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/commentrefe...)
Please test it and let me know if there are still any issues. If all goes ok, I'll release it somewhere next week!
#7
Checking it out
#8
I'm not seeing the new settings... where should they be?
Edit: had wrong version of the file. See the settings now. Testing.
#9
This is working fine for me. So far, I only have a couple dozen comments (not live site yet), but works well on these.
Have another suggestion, but I'll put it in a new feature req.
#10
This is working fine for me. So far, I only have a couple dozen comments (not live site yet), but works well on these.
Have another suggestion related to this: how hard would it be to display the CID in the autocomplete along w/the info that displays there now (time, etc.)?
#11
Anything is possible, I committed it to the D6 branch - untested though, hope I didn't introduce a parse error :) (grab from CVS or wait for the next build)
#12
Tested. No parsing errors. Seems to work fine, and looks good. Thanks.
#13
Ok, cool, I'll create a new release somewhere this weekend, thanks for testing!
#14
One small issue: when I include the commentreference field in a View (as a linked title), it also displays the time as "x days x hours ago" ... which is cluttering up the View a bit since I don't really need that info in there. Not sure why that happens. It would be OK, too if I knew where to change the format to something more compact instead of "ago" time.
#15
I'll test that this weekend, I'll keep you up to date.
#16
Overriding the output of that view can be done by overriding either 'theme_commentreference_formatter_default' or 'theme_commentreference_formatter_plain'. Those functions are included by default in the comment reference module. Drupal lets you override them so I'm not going to include options to change the output. For more info about theming override see http://drupal.org/node/341628
A new release will be out tomorrow normally!
#17
Setting to better status
#18
Well, I have to learn to write overrides sooner or later. Might as well be now...
What I understand is that I want to do an implementation of hook theme_commentreference_formatter_default (is that the right lingo?) in my theme's template.php file.
... and "theme_" has to change to "superdupercustomthemeImademyself_" Right so far?
In the .module, I see this...
function theme_commentreference_formatter_default($element) {$output = '';
if (!empty($element['#item']['cid']) && is_numeric($element['#item']['cid']) && ($title = _commentreference_titles($element['#item']['cid']))) {
$referenced_comment = _comment_load($element['#item']['cid']);
$output = l($referenced_comment->subject, 'node/'. $referenced_comment->nid, array('fragment' => 'comment-'. $referenced_comment->cid)) .' - '. t('@time ago', array('@time' => format_interval(time() - $referenced_comment->timestamp)));
}
return $output;
}
So I want to put all that in my template.php file, replace "theme_" with whatever, then change things to get the look I want.
So, any hints on what I should change? I don't really know what any of it means.... wait a sec. Maybe I do... enough to do some guessing. Will play with this and see what results I get. Meanwhile, if you have a sec. and can straighten me out where I'm wrong, much appreciated.
#19
Got it. Just did the above and then removed
.' - '. t('@time ago', array('@time' => format_interval(time() - $referenced_comment->timestamp)))#20
Automatically closed -- issue fixed for 2 weeks with no activity.