different style profile page for different user groups

Permalink
Does anyone know if it's possible to have different style public profile pages for different user groups and how I would achieve this.
Thanks

rosie607
 
adajad replied on at Permalink Reply
adajad
Don't know if this is the best way to address this, but you could add inline styles in the head when there is a profile in play (will be in effect on all profile pages, or pages having blocks utilizing the profile object).

In your theme header.php file you can add the following code just before your ending head tag. Header.php is located in 'public_html/themes/your_theme/elements' or 'public_html/packages/theme_name/elements' if it's not a core theme.

<?php
if(is_object($profile)){                                                  // if $profile is in play - do stuff
   $u = User::getByUserID($profile->getUserID());                         // get the user object for the user profile you are on
   if($u->inGroup(Group::getByName('level_1_group_name'))){               // If the user is in group named 'level_1_group_name'
      echo '<style type="text/css">body{background:#F5A9F2;}</style>';    // - then set the background color to something pinkish
   }elseif ($u->inGroup(Group::getByName('level_2_group_name'))) {        // If the user is in group named 'level_2_group_name'
      echo '<style type="text/css">body{background:#CEE3F6;}</style>';    // - then set the background color to something blueish
   }elseif ($u->inGroup(Group::getByName('level_3_group_name'))) {        // If the user is in group named 'level_3_group_name'
      echo '<style type="text/css">body{background:#A9F5A9;}</style>';    // - then set the background color to something greenish
   } //and so on
}
?>
</head>


In the code above you need to change the group names to match your groups, and keep in mind that a user can be in more groups than one. Think about which groups should take precedence in the styling and have them in descending order in the if statements. Also change the styling to whatever you want. In the example above I just changed the background color for testing purposes.
rosie607 replied on at Permalink Reply
rosie607
Thanks for your help, I really wanted to actually have separate pages but if I can't figure out how to do that I think this will work by using different css for different user groups. Thanks
adajad replied on at Permalink Reply
adajad
Actually, all profiles use the same page (a single page called profile) to output the information. The best way to have it look different is to apply different styles, unless you want more elements and a completely different design with significant structural changes. That can also be arranged, but it will be a bit harder for you.

In the code above I added inline styles, but you can as well add whole style sheets, if there are many style changes, just as you normally do in your theme.

Anyways, I hope you get it sorted.

...and as I said, there are more ways than the one above to accomplish what you want.
rosie607 replied on at Permalink Reply
rosie607
Hi Thanks
Like you said, what I want to do is actually have different profile pages which are significantly different.
I tried copying the profile page to my single pages folder and renaming profile_s2 but when I view the page it's empty.
View source shows only the following
<div id="ccm-profile-wrapper">
    <div id="ccm-profile-sidebar">
   <div class="ccm-profile-header">


Any ideas how I would make this work?
Thanks heaps