0

I wan't to be able to change the site logo depending on which user that are logged in. My guess is that I would be able to do something in page.tpl.php that check's if there is a user image and if true replaces the default logo with user logo.

How can I do this the Drupal way?

closed as too broad by Mołot, Free Radical, Letharion, Jimajamma, niksmac Mar 23 '14 at 16:46

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Hello. We don't have a code writing service here ;) You know you need to edit page.tpl.php. You need to use theme_preprocess_page to feed additional data to it. When you will have your modifications in progress, post your code and actual problems that you face. – Mołot Jan 10 '14 at 13:28
  • Ok I get the hint. ;) Thanks for the tip though. – Edd Clark Jan 10 '14 at 13:37
  • I don't like to leave people clueless, even if I think they should have try a bit harder on their own before asking. Note that questions about code, but without said code, are not exactly allowed, so it is not just my whim. – Mołot Jan 10 '14 at 13:42
  • Ok, that's good to know. – Edd Clark Jan 10 '14 at 13:49
4

Hope this will help you,

In Drupal 7 you can use template_preprocess_page in template.php file


/**
 * Implementing template_preprocess_page
 */
function YOUR_THEME_NAME_preprocess_page(&$vars) {
  global $user;
  if (in_array('authenticated user', $user->roles)){//change role based on your requirement
      $vars['logo'] = 'Your logo path';
  }
}
1

If roles don't matter and you just need to check logged in or logged out, a nice clean Drupal way to do this is, in your template.php file:

/**
 * Variable preprocessor for the page.tpl.php template.
 */
function THEMENAME_preprocess_page(&$variables) {
  // Change the logo for logged in users.
  if (user_is_logged_in()) {
    $vars['logo'] = 'Your logo path';
  }
}

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