4

I'm using Drupal 7 and I want to create another (different) html.tpl.php file for logged in users only.

So, I need to check if user is logged in and set other html.tpl.php file if a user is logged.

Is this possible and how to do that?

1 Answer 1

12

Implement hook_preprocess_html() in your theme (or module, both are equally valid) like so:

function MYTHEME_preprocess_html(&$vars) {
  // Determine if the user is auth'd
  if (user_is_logged_in()) {
    // Add a theme hook suggestion.
    $vars['theme_hook_suggestions'][] = 'html__auth';
  }
}

Then add a html--auth.tpl.php file to your theme, clear the caches, and you should be good to go.

2
  • works like a charm...thanks a lot...is there way to do the same thing but for specific pages (urls)?
    – mixerowsky
    Sep 17, 2013 at 15:25
  • I think this is what you're looking for...
    – Clive
    Sep 17, 2013 at 15:55

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.