I can create a list of profiles of a specific type. That works great. But what's stumping me is I need a view that has fields that pertain to a specific person. Say for instance you are on Bob's "personal" profile and there is a block that has information for bob's second "business" profile (or any other member's other profiles for that matter). How do I create a block for this profile with relative fields that only populates on demand?....
You can use the Views module to access the Profile2 fields.
- 5.1 create View (Show:User)
- 5.2 add relationship, (User:Profile); give the Identifier a unique name ie 'MainProfile'; select a single checkbox for 'Profile type',
in my case 'Main profile';
- 5.3 add another relationship, (User:Profile); give the Identifier a unique name ie 'EducationProfile'; select the other checkbox for
'Profile type', in my case 'Education profile';
- 5.4 add Fields to view; select Profile2 field items; use Relationship dropdown in 'Configure field' to associate w/ correct relationship;
You can output as a Block, and use the Page URL to retrieve the correct user ID to load. (For your views context)
You can use the profile2_load_by_user(); function to programmatically retrieve Profile2 data.
$profile_data = profile2_load_by_user($user->uid);
See also: profile2_load_multiple()