What I want to do is...
If you're an anonymous (role) user, the website uses garland theme.
If you're an athenticated user, the website uses garland theme.
If you're an admin user, the website uses chameleon theme.

I have 3 roles:
anonymous (default - locked)
authenticated (default - locked)
admin (I created this)

Thank you in advance.

Comments

PierreM-1’s picture

Actually, each user can select its own theme by itself.

You can set a default administrative theme for user #1 as well.

Some other ideas: http://drupal.org/node/79782

Sree’s picture

is it possible to assign different themes for differen roles?

users r not given the option to select their themes but, depending on the user role the theme shld b changing!

-- Sree --
IRC Nick: sreeveturi

roncjl’s picture

I did mine this way:


<!-- load theme CSS based on user role -->

<?php global $user; if (in_array('Role Name',$user->roles)): ?>	    
     
<link rel=StyleSheet type="text/css" href="<?php print $base_url ?>/sites/all/themes/ThemeFolderName/themecssfile.css" media=all></link>

<?php endif; ?>

Making it load different CSS file (which means different theme) based on user role.

Then for further theming, the HTML and PHP part, i used the same technique:


<?php global $user; if (in_array('Role Name',$user->roles)): ?>

<!-- the DIV calls, etc. for the respective theme here -->

<?php endif; ?>

All that in one file, which usually is page.tpl.php

The end file looks like this:


<head>

<!-- load theme CSS based on user role -->

<?php global $user; if (in_array('Role Name ONE',$user->roles)): ?>	    
     
<link rel=StyleSheet type="text/css" href="<?php print $base_url ?>/sites/all/themes/ThemeFolderNameONE/themecssfileONE.css" media=all></link>

<?php endif; ?>

<?php global $user; if (in_array('Role Name TWO',$user->roles)): ?>	    
     
<link rel=StyleSheet type="text/css" href="<?php print $base_url ?>/sites/all/themes/ThemeFolderNameTWO/themecssfileTWO.css" media=all></link>

<?php endif; ?>

<!-- end of CSS load -->

</head>

<body>

<!-- load HTML PHP elements based on user role -->

<!-- here is Theme ONE -->

<?php global $user; if (in_array('Role Name',$user->roles)): ?>

<!-- the DIV calls, etc. for the theme ONE here -->

<?php endif; ?>

<!-- here is Theme TWO -->

<?php global $user; if (in_array('Role Name',$user->roles)): ?>

<!-- the DIV calls, etc. for the theme TWO here -->

<?php endif; ?>

<!-- end role-based HTML PHP elements load-->

</body>

For PHPTemplate engine. Assuming you know CSS and HTML though, and if you are designing your own theme. This way also i get to package the theme (including its alternate role-based themes in one package of theme). I feel there is a better way somehow, just don't seem to find it around here in the forum. Can someone link me if they know?

Thanks in advance :)

greggles’s picture

Shortly after this forum topic was posted a module was created which does exactly this.

See http://drupal.org/project/role_theme_switcher

--
Open Prediction Markets | Drupal Dashboard | Learn more about Drupal - buy a Drupal Book