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.)
Comments
Comment #1
swentel commentedSounds reasonable as request, I'll take a look how node reference does this somewhere next week. I'll keep you posted on the progress.
Comment #2
swentel commentedQuick 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 ?
Comment #3
aharown07 commentedWell, 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.
Comment #4
swentel commentedHaving 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.
Comment #5
aharown07 commentedSuper. Many thanks.
Comment #6
swentel commentedHi, 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!
Comment #7
aharown07 commentedChecking it out
Comment #8
aharown07 commentedI'm not seeing the new settings... where should they be?
Edit: had wrong version of the file. See the settings now. Testing.
Comment #9
aharown07 commentedThis 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.
Comment #10
aharown07 commentedThis 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.)?
Comment #11
swentel commentedAnything 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)
Comment #12
aharown07 commentedTested. No parsing errors. Seems to work fine, and looks good. Thanks.
Comment #13
swentel commentedOk, cool, I'll create a new release somewhere this weekend, thanks for testing!
Comment #14
aharown07 commentedOne 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.
Comment #15
swentel commentedI'll test that this weekend, I'll keep you up to date.
Comment #16
swentel commentedOverriding 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!
Comment #17
swentel commentedSetting to better status
Comment #18
aharown07 commentedWell, 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...
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.
Comment #19
aharown07 commentedGot it. Just did the above and then removed
.' - '. t('@time ago', array('@time' => format_interval(time() - $referenced_comment->timestamp)))Comment #21
donquixote commentedHi Swentel,
I would prefer an option to filter by node type, similar to nodereference.
Please tell me if I should make a new request for that. To me it looked like the topic starter had something similar in mind initially (views filtering would include filtering by node type).
My use case is similar to the topic starter, I want to restrict the reference to forum comments.
If you have any idea to let a custom module do the filtering, please let me know.
Thanks!
Comment #22
donquixote commentedOk, guess I could use hook_menu_alter() on the autocomplete callback, and hook_nodeapi('validate'). Still, would be nice to have this built-in.
Comment #23
swentel commentedHrm, filtering on node type is a valid request actually, should be possible to add that as an option. Should be relativily easy to add a new option into commentreference_field_settings() - and also a good moment to create a helper function since I'm really having a lot of duplicate code for checking those settings :) . I'm organising a code sprint at work somewhere this month, so I'll have some time then to implement this.
Comment #24
swentel commentedJust marking postponed, don't have time for this one now.