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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityImplement 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.