Display different modules for different Multi Profiles

NOTE: It's recommended for you to have backup of the edited template file. Solution is tested with JomSocial


This solution will allow you to display different modules for each Multi Profile.


Be aware that template may differs with the way modules are rendered. My hack should work with most templates as I used standard method of module rendering.

You'll need to edit index.php of your template (if you use T3 framework based template or any other frameworked template then you'll need to find yourself right place where sidebars are loaded).

In my example I'll use Protostar template as default Joomla! 3.x.x template.

1. Edit file ROOT/templates/protostar/index.php. In line 174 starts RIGHT sidebar. Here we'll add our code so any module assigned to multiprofile ID will be loaded before any other modules - so on top of column).

2. After line 174 add this code:

$user = JFactory::getUser();
$user_profile_id = $user->getProfileType(); 						
<?php if($user_profile_id == 2) { ?>
<jdoc:include type="modules" name="position-name" style="style-name" />
<?php } ?>

First part of code check current user id and query database for multiprofile ID related to it.
Second part is a condition that says if current user related multiprofile id is equal to 2 then load below module position.

So you must know multiprofile ID (you'll find it in Backend -> Components -> JomSocial -> Profiles -> Multi Profiles and first column in table marked as #).

position-name - replace with your own using non-latin letters and no spaces and special signs except - and _. Module position name MUST BE UNIQUE!

style-name - if you know what module style name are defined in your template, you can use style name here.

3. If you have more multiprofiles and want to display different modules for each then just copy this part:

<?php if($user_profile_id == 2) { ?>
<jdoc:include type="modules" name="position-name" style="style-name" />
<?php } ?>

4. Change 2 to other multiprofile ID, change module position name. Repeat it for every multiprofile you have.

5. When assigning module to positions you created here - you'll have to type module position name manually as it will be not listed for the first time.

See Also