integrate taxonomy terms attached to node profile with views

bonzo meier - April 7, 2009 - 08:05

hola, drupalistas!

maybe someone can help me out with this question: i am using an extended user profile setup with nodeprofile, because i want taxonomy terms to be associated with user profile pages. no problem so far. but when i set up user listings via views (using table view), the taxonomy terms picked in the profile nodes are not available in the listing. i can pick them as a table field to display in the view table (i tried 'Content Taxonomy Field: field_myfield', 'Taxonomy: Terms for myVocabulary', 'Taxonomy Field: myfield (field_myfield)', and even 'Taxonomy: All Terms'), but no data is displayed.

can someone give me a hint how to set up a proper user listing with taxonomy terms associated by nodeprofile?

thanks in advance,
bonzo meier

half way there - but now?

bonzo meier - April 7, 2009 - 12:26

okay, i am half way there.

i added the following code to the beginning of my node-usernode.tpl.php (before the 'if ($teaser == TRUE)' stuff starts, because i want it available for ALL display types)

<?php

// make nodeprofile tags available as $taxonomy / $terms
$profile_tags = nodeprofile_load('my_nodeprofile_node_type', $user->uid);
if (
$profile_tags) {
   
$taxonomy = $profile_tags->taxonomy;
   
$terms = '';
   
    foreach (
$taxonomy as $tid => $term) {
       
$terms  .= l($term->name, 'taxonomy/term/'.$tid).'&nbsp;';
    }
}
?>

then i had a view set up with a filter 'node type is one of usernode', which works just perfectly on 'full nodes' and 'teaser list'-style-views, with terms and everything.
but still, the table view will not show the terms...

ideas anyone?

peace,
bonzo

p.s.: by now you´ve probably figured out that i use both 'node profile' and 'usernode' modules...

another half way there...

bonzo meier - April 7, 2009 - 14:40

in the meantime i found that there´s a great module called views fusion (http://drupal.org/project/views_fusion), which is actually supposed to do what i want.

what i did with this is:

- create a parent-child-relation between my content types 'usernode' and 'my_nodeprofile_contenttype' with 'usernode' being 'parent' using nodefamily module.
- set up a second view 'sublist' as table view, with only one filter 'content type is one of 'my_nodeprofile_contenttype'' and only one field ('Taxonomy: All Terms'). the 'sublist' view produces a table with all the taxonomy links from 'my_nodeprofile_contenttype'-content! WOW! well, WOW so far...
- set up a views fusion with 'primary view' set to 'userlist' and 'fuse with view' set to 'sublist' and 'nodefamily relation: parent - child'.

now i end up with my 'userlist' view with a table that displays all the right columns, the ones from the original 'userlist' PLUS the additional 'sublist' column.

...but there´s still NO DATA in the fusioned sublist-column!

can someone please help? ANYone? please?

bonzo

i got it!

bonzo meier - April 7, 2009 - 14:55

the 'views fusion' thing is the way to go:

my former subview (containing the nodeprofile-taxonomy-terms) must be set up as primary view, my former mainview 'userlist' became the 'fused view' and the relationship is set to 'child-parent'.

this works perfectly! sometimes it helps to set things upside-down...

i love 'views fusion'!

and anyone else trying to use taxonomy with profiles and user listings will love it too!

 
 

Drupal is a registered trademark of Dries Buytaert.