Here's some files that add views support.
I was halfway through coding the exact same module as this for a project when I found this module, so you'll have to change the hook names and the handler prefix to your module.
However, I was using the same table so all the views data stuff is ok.
You'll need a hook_views_api() in your main module too.
If I have time later I'll try to make a proper patch for your module :)
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 574524-3.user_terms.views-support.patch | 5.75 KB | joachim |
| #12 | user_terms_views_2-D6.patch | 5.03 KB | stefan freudenberg |
| #10 | user_terms_views-D6.patch | 4.86 KB | stefan freudenberg |
| #7 | user_terms-views.zip | 1.89 KB | akoe |
| user_terms-views.zip | 1.9 KB | joachim |
Comments
Comment #1
joachim commentedThe handler needs work, it turns out :(
pre_render() needs work, as it gets ALL values, so the $vids approach from views_handler_field_term_node_tid is needed after all.
Comment #2
akoe commentedIm intrested in views support for user terms too, but i didnt really get what you posted :-(
Is it possible to explain it a little more how to patch the module with your code?
Comment #3
joachim commentedYou need:
- a hook_views_api() in the main module.
- rename the hooks in the file I attached above
- optional, but for consistency the handlers should have the module name as their prefix.
See the views docs for how this all works.
Comment #4
akoe commentedthanks for your quick reply! i managed to add and seems to work quite well.
so thanks again.
Comment #5
todd nienkerk commentedAssigning to Robert to complete.
Comment #6
anasynth commentedHi,
I don't have the coding skills to implement views supporting using the .zip attachment. Is a patch going to be made available for this functionality?
Comment #7
akoe commentedaccording to joachims hint at #3 i modified his attachment to appending files.
you have to copy them in user terms module directory.
in the file user_terms.module you have to paste following code lines (according views docu http://views.doc.logrus.com/ ):
Comment #8
davidbessler commentedI added the files into the user_terms module folder, and added those lines (without the opening and closing php tags I assume) into the user_terms.module file. Now how to I then use it in views? I want to filter users with a taxonomy term.
Comment #9
perkethanks akoe, I just used it and it works as charm
@davidbessler, yes.. there is User: Term filter under the User group
Comment #10
stefan freudenberg commentedI made a patch based on the zip file. It already takes care of the problem mentioned in #1. This still needs work because it reads all uid tid combinations not only those of the displayed users.
Comment #11
joachim commentedYou mean the query in pre_render() that doesn't have a WHERE clause?
There are other handlers in Views that tackle this -- look at the taxonomy ones probably.
You get the uids we're interested in from $values and build an array of them, which you then implode to make a 'WHERE ... IS IN ()' clause.
Sorry, not got time to do this myself.
Comment #12
stefan freudenberg commentedThanks for the hint. Please review!
Comment #13
youkho commentedSubscribe
Comment #14
joachim commentedThanks for all your work on this.
I've committed this patch; it has a few modifications from the earlier one such as making the field work in relationships.
The -dev version will be updated shortly if you want to give it a try.
#574524 by akoe, Stefan Freudenberg, joachim: Added Views support.
Comment #15
scalp commentedI'm using the latest beta version of User Terms which looks like it already includes this patch, but I'm not seeing any fields or arguments in Views related to User Terms. Am I missing something?
Comment #16
joachim commentedYou maybe need to clear your views cache.
Comment #17
scalp commentedI tried that. Also checked to make sure I'm using an up to date version of Views 2. What additions to Views should User Terms be making? I'm not seeing any.
Comment #18
joachim commentedI don't have my test setup with me; the file will tell you. You should get a field, a filter, and argument.
Comment #19
scalp commentedGot it working on a "User" view. Would it be possible to add integration with a "Node" view? The "User" view is really limited on what arguments and fields you can use. For anyone using CCK it would seem that a "Node" view is what will really be needed. It looks like it's written to be able to do so based on the user_terms_handler_field_term_user_tid.inc file.
Comment #20
joachim commentedFor a node view, add the Node revision: User relationship to get to the user first.
(I should start a docs page for this...)
Comment #21
joachim commentedExcept I can't find where to put a docs page. *sigh*
Comment #22
scalp commentedThat did the trick! Thank you so much. After adding the relationship and saving the view you can come back to it and the extra fields, args and filters are there.
Comment #23
scalp commentedI've tried to set up this situation on another site. Here's the error I'm getting:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND td.vid IN (2) ORDER BY td.weight, td.name' at line 1 query: SELECT td.*, tu.uid, v.name as vocabulary FROM term_data td INNER JOIN term_user tu ON td.tid = tu.tid INNER JOIN vocabulary v ON v.vid = td.vid WHERE tu.uid IN () AND td.vid IN (2) ORDER BY td.weight, td.name in /var/www/modules/user_terms/user_terms_handler_field_term_user_tid.inc on line 63.
Any ideas?
Comment #24
joachim commentedWhere are you seeing that?
What kind of view? Does it have no results?
Comment #25
scalp commentedYes. Only when there are no results. It is a node view.
Comment #26
joachim commentedI've filed a new issue for this: could you test the patch at #705990: a view with just the anon user produces an SQL error please?
Comment #27
scalp commentedReplied on there. Patch works great! Thank you very much.