K here is what I am trying to do.

Populate the view based on taxonomies applied to each currently logged in users nodeprofile.

a bit more detail...

Each user belongs to one or many taxonomy terms - this is achieved through assigning taxonomy terms to their nodeprofile
When they look at this "View" it will filter the content depending on the taxonomy terms applied to their nodeprofile

Any ideas here?

Comments

Aar0n’s picture

I have found a module http://drupal.org/project/relatedviews that is along the track of what I am trying to achieve

This module uses a filter "Taxonomy: Term from current node" which uses the first taxonomy term on the current node to filter to the view.

This is similar to what I am looking for except it does not offer the following features
*Only selects from the current node being viewed --- Want to be able to filter based on the current users nodeprofile
*Only filter using the first taxonomy term of the node ---- Want to be able to filter using all the taxonomy terms of the node

imrook’s picture

I helped develop the related views module and I can tell you it won't do exactly what you're trying to do. I can also tell you there isn't an existing module (or combination of modules) that will either. You're either going to have to extend the existing modules or write a bit of custom glue to get what you want. I would recommend you add a views filter to the nodeprofile module such as "Taxonomy: Term from current user's nodeprofile" The implementation would be something like this:

<?php
// Get usernode nid
$nid = usernode_get_node_id($user->uid);

// Load all nodeprofile nodes
$children = nodefamily_relation_load_all_nids($nid);

// Get all taxonomy terms for nodeprofile
foreach($children as $child){
  $terms[] = taxonomy_node_get_terms($node->nid);
}
// Add taxonomy terms to view query 
?>

Hope that helps!

Aar0n’s picture

I have managed to customize the relatedviews module so far to get the currently logged in users unique profile and grab the taxonomy terms out of it but It will only filter by one term still (I want to filter by all the terms in the node), which i cant figure out. (note: im a n00b).

If some one could maybe have a tinker with the code below or give me a couple of pointers that would be much appreciated.

function relatedviews_handler_filter_taxcurnode($op, $filter, $filterinfo, &$query) 
{
  global $user;
  $nid = NULL;
  $vid = NULL;
  //uprofile is the name of the content type for each users profile
  $result = db_query("SELECT nid FROM node WHERE type = 'uprofile' AND uid = ".$user->uid);
  $items = array();
  while ($row = db_fetch_object($result)) {
	$nid = $row->nid;
  }

  if (!is_null($nid)) {
    $vid = $filter['value'][0];

    $terms = array_keys(taxonomy_node_get_terms_by_vocabulary($nid, $vid));
    $term = $terms[0];

    _views_add_taxonomy($filter['operator'], array($term), $filter['options'], $query);

    $query->where[] = "node.nid != '%s'";
    $query->where_args[] = $nid;
  } // if we've got a node

  // if there is no node, the view shouldn't return anything.
  if (is_null($nid)) {
    $query->where[] = "0";
  } // if there is no node
} // function relatedviews_handler_filter_taxcurnode

imrook’s picture

This is in NO WAY tested. I am meerly looking at the code and drawing conclusions that may be wrong. When I inspect the code, it seems that we get all the terms and then throw all of them except the first one out. We then create an array from the single term we kept and pass it to the views module. The changes below should be a good place to start:

<?php
    $terms = array_keys(taxonomy_node_get_terms_by_vocabulary($nid, $vid));
    //$term = $terms[0];

    _views_add_taxonomy($filter['operator'], $terms, $filter['options'], $query); // Pass $terms instead of array($term)
?>