I have 3 profiles types in profiles2. Each Profile type is assigned to a corresponding role.
I would like to change the display or layout of the users profile page and also show fields from the profile2 profile attached to that users role.

Is there a way i can easily do this?

thank you.

Comments

John_B’s picture

You could use Views. I checked your profile to see which method would suit best, and see that you are a Senior Web Developer, so I would recommend just making different templates, as per the answer here http://drupal.stackexchange.com/questions/114441/profile2-template-for-p.... However, the uderscore in that answer could give you problems: based on experience with such problems, I would recommend ensuring that the machine name for your profile types does not include any underscore or hyphens.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

baffourasante’s picture

Thanks for the response. I have tried making custom templates for the profile2 profile types just as in the link above but that doesn't really solve my problem. I want to show fields from the default drupal user profile as well as fields from profiles2 on the same page using the user-profile.tpl.php file. but i have 3 profile types in profile2 (student, employer and mentor. these also have corresponding roles) and each user is assign one out of the 3 profiles. on the student page, i want to be able to print the profile picture along with some profile2 fields on the sidebar and print the other profile2 fields in the content area. is there a way to create separate user-profile.tpl.php files for each role?

I have tried using views but couldn't figure out how to set the paths correctly. I am able to get it working with views for one role but cant figure out how to add the other roles.

John_B’s picture

is there a way to create separate user-profile.tpl.php files for each role?

Not for each role but for a separate template for each profile type, which in your case is the same thing. That is what the link I provided said. Either we have a misunderstanding or you did not read it? I have not tried it. However, Profile 2 does seem to provide this.

I am aware I have not answered the question about image in sidebar. First thing is to get the contextual filter working in the Views preview; once you have that, you have that you can usually sort out the specific problems of a contextual filter with a block. For contextual filter with Profile 2 you could look at this http://drupal.stackexchange.com/questions/44738/can-someone-help-me-with....

The problem is that the role is not part of the user object user account object in profile 2, so you would need to extract the role by a database call, or, since you already know know the role by the profile type, you would need to check the profile type. If the each profile type had a unique path, e.g. profile3/123 profile4/124 profile5/125 you could use that path element in a Views contextual filter, in block visibility settings or to make custom templates and it would be easier.

There are probably solutions using Display Suite or Panels Everywhere - I have used those tools but do not know them in any depth.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

baffourasante’s picture

thanks for the response. I will try out the recommendations.