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 :)

Comments

joachim’s picture

The 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.

akoe’s picture

Im 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?

joachim’s picture

You 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.

akoe’s picture

thanks for your quick reply! i managed to add and seems to work quite well.
so thanks again.

todd nienkerk’s picture

Assigned: Unassigned » rgristroph

Assigning to Robert to complete.

anasynth’s picture

Hi,

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?

akoe’s picture

StatusFileSize
new1.89 KB

according 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/ ):

function user_terms_views_api(){
	return array(
	 'api' => 2,
	 'path' => drupal_get_path('module','user_terms'),
	);
}
davidbessler’s picture

I 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.

perke’s picture

thanks akoe, I just used it and it works as charm

@davidbessler, yes.. there is User: Term filter under the User group

stefan freudenberg’s picture

StatusFileSize
new4.86 KB

I 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.

joachim’s picture

You 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.

stefan freudenberg’s picture

Status: Needs work » Needs review
StatusFileSize
new5.03 KB

Thanks for the hint. Please review!

youkho’s picture

Subscribe

joachim’s picture

Status: Needs review » Fixed
StatusFileSize
new5.75 KB

Thanks 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.

scalp’s picture

I'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?

joachim’s picture

You maybe need to clear your views cache.

scalp’s picture

I 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.

joachim’s picture

I don't have my test setup with me; the file will tell you. You should get a field, a filter, and argument.

scalp’s picture

Got 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.

joachim’s picture

For a node view, add the Node revision: User relationship to get to the user first.

(I should start a docs page for this...)

joachim’s picture

Except I can't find where to put a docs page. *sigh*

scalp’s picture

That 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.

scalp’s picture

I'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?

joachim’s picture

Where are you seeing that?
What kind of view? Does it have no results?

scalp’s picture

Yes. Only when there are no results. It is a node view.

joachim’s picture

I'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?

scalp’s picture

Replied on there. Patch works great! Thank you very much.

Status: Fixed » Closed (fixed)

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