I would like to be able to filter comments by comment depth. Comment depth is available for sort as well as a field, but not as a filter. I've attached a patch which accomplishes this, however the SQL it uses may not be compatible with systems other than MySQL. This is why it needs review. The SQL in question is:

    $field = "(LENGTH(" . 
             $this->table_alias . 
             ".thread) - LENGTH(REPLACE(" .
             $this->table_alias . 
             ".thread, '.', '')))";

which results in SQL like:

(LENGTH(comment.thread) - LENGTH(REPLACE(comment.thread, '.', '')))

This unfortunately cumbersome SQL counts the number of periods in the comment.thread field by subtracting the length of the field with periods replaced from the length of the full field. If this can be done with PHP here instead, or some more database-neutral way, I strongly suggest that be done.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msielski’s picture

If you apply this patch be sure to clear your views cache so you can see the new filter option.

himerus’s picture

Did you ever get further with this? or a better alternative?

I'm currently trying to implement this via a custom handler in my own module rather than patching.

esmerel’s picture

Status: Needs work » Closed (won't fix)

No work on patch in more than 3 months

vidorado’s picture

Status: Closed (won't fix) » Needs review
FileSize
1.71 KB

I've found a better alternative than the original patch, modifying only the views module instead of modifying both views and comment modules (hacking a module is bad, but i think that hacking the core is very bad...).

I don't know yet how to make CVS compatible patches from GIT, so my patch won't pass the automatic test, but it works. It's tested with views-6.x-3.0-rc1

Hope that helps (and it would be wonderful if merlinofchaos could commit it to the dev branch so we don't get crazy with our future updates of views).

NoRandom’s picture

Was this patch finally included in the release version?

Could someone port it to the 7.x branch?

Status: Needs review » Needs work

The last submitted patch, views-6.x-3.0-rc1.comment-depth-filter.patch, failed testing.

MustangGB’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)