3

I'm trying to create a custom front page for user that are not logged in. Something like page--front-anonymous.tpl.php

I can put an if function in the page--front.tpl.php to check the role but i believe it should be possible to create a separate template file.

Any advise?

3

in your THEME_preprocess_page(&$vars) hook you can put something along the lines of...

if ($vars['is_front'] && !$vars['logged_in']) {
   $vars['template_files'][]='page-front-anonymous'; // drupal 6
   $vars['theme_hook_suggestions'][]='page_front_anonymous'; // drupal 7
}

which should work using the is_front and logged_in variables set by the various modules before you get to it. if you are using a module, and don't want to rely on weight/execution order, you could do it with:

global $user;
if (drupal_is_front_page() && !$user->uid ) {
.....
1

I'm not sure how complicated your page is, but if all of you content is in blocks, you can adjust block visibility using the block access module on a per-role basis. I did that on a project - I ended up with one template file, but different pages based on whether or not someone was logged in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.