Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have the Content Profile module installed. With this module, each user has 1 to many locations that are attached to them.

These locations are created via a content type called locs.

I have another content type called todays_spot that also has a selectable location (only one) also being dynamically created via locs.

So I'm pulling some of the todays_spot data out via a view, but I need to filter it so it only displays data if the user location(s) match.

Any suggestions, I've looked all over and can't find a thing.

share|improve this question
    
Are you using a node reference to the locs content? –  WestieUK Feb 8 '12 at 9:12
    
@Westie: yes, the content profiles, as well as todays_spot uses the same Node reference to locs. –  kylex Feb 8 '12 at 16:08
add comment

1 Answer

See this post for a solution in Drupal 7, but the same principle applies here.

Create an argument for the related loc of todays_spot.
Choose the the right relationship (node, I think), and select 'provide default argument'
Use 'PHP Code' as your default argument

You'll need to modify the code below to match your system, but it should resemble the following:

global $user;
// the code below loads via the Profile2 module, but something similar
// will work with Content Profile, but you'll need to inspect the code
// to find a function similar to `profile2_load_by_user`
// I'd start by inspecting the $user variable with print_r or dd();
$profile = profile2_load_by_user($user->uid,'facilitator');
if (!$profile) { return ''; }
if (!isset($profile->field_location['und'])) { return ''; }
$locations='';
foreach ($profile->field_location['und'] as $location) {
  $locations.=','.$location['nid'];
}
return substr($locations,1);

Don't forget to select 'Allow Multiple Terms Per Argument' before saving your new argument.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.