views:

97

answers:

1

I have a web site at what-i.com that uses Drupal Commons profile. I have created a custom theme called 'whati' and placed it in /sites/all/themes folder. My page-front.tpl.php is supposed to drive my front page.

It has an if-else statements for 2 scenarios: logged in and non-logged in users. For logged in users, everything works great: upon logging in, the user sees my custom front page. For non logged (anonymous) users, it always forwards them to http://what-i.com/user?destination=home. I don't know how to override that redirect: it does not pick up on the if statement in my page-front.tpl.php, I tried using frontpage module with no success, and I also tried to change the front page settings under Site Information to no avail.

Can anybody help me to resolve this issue: that is, instead of being redirected to user?destination=home, I want my anonymous users to see a custom front page I created.

+1  A: 

You can do this from a TPL file or a module init().

From a x.tpl.php:

if (drupal_is_frontpage()) {
   global $user;
   if ($user->uid == 0) {
       drupal_goto('some page');
   }
 }

From a module:

mymodule_init() {
   global $user;
   if ($user->uid == 0 && drupal_is_frontpage()) {
      drupal_goto('some page');
   }
}
Kevin
Kevin, when I tried your solution and placed the code at the top of page.tpl.php file, my page goes into infinite redirect loop. How can that be fixed? Thanks.
Sorry, wrap that whole statement with if ($is_front) { //code }. That should fix that. Updated my answer.
Kevin
This code can be simplified by using the drupal_is_front_page() function: http://api.drupal.org/api/function/drupal_is_front_page/6
jhedstrom
Never knew that existed
Kevin