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

swentel’s picture

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.

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

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 ?

aharown07’s picture

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.

swentel’s picture

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.

aharown07’s picture

Super. Many thanks.

swentel’s picture

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!

aharown07’s picture

Checking it out

aharown07’s picture

I'm not seeing the new settings... where should they be?

Edit: had wrong version of the file. See the settings now. Testing.

aharown07’s picture

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.

aharown07’s picture

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.)?

swentel’s picture

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)

aharown07’s picture

Tested. No parsing errors. Seems to work fine, and looks good. Thanks.

swentel’s picture

Ok, cool, I'll create a new release somewhere this weekend, thanks for testing!

aharown07’s picture

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.

swentel’s picture

I'll test that this weekend, I'll keep you up to date.

swentel’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

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!

swentel’s picture

Status: Closed (fixed) » Fixed

Setting to better status

aharown07’s picture

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.

aharown07’s picture

Got it. Just did the above and then removed .' - '. t('@time ago', array('@time' => format_interval(time() - $referenced_comment->timestamp)))

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

donquixote’s picture

Title: use views to filter comments » use views to filter comments / filter comments by node type
Status: Closed (fixed) » Active

Hi 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!

donquixote’s picture

Ok, guess I could use hook_menu_alter() on the autocomplete callback, and hook_nodeapi('validate'). Still, would be nice to have this built-in.

swentel’s picture

Title: use views to filter comments / filter comments by node type » Filter comments by node type

Hrm, 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.

swentel’s picture

Status: Active » Postponed

Just marking postponed, don't have time for this one now.