I have a mod of Garland 6 and I would like to have different body.png for anonymous and authenticated users. In style.css I found the class #wrapper that I have to change somewhat. I got some help on IRC, but I couldn't figure out how to make it work. Is there anyone who could help me?

In page.tpl.php

<!-- Layout -->
  <div id="header-region" class="clear-block"><?php print $header; ?></div>

    <div id="wrapper">
    <div id="container" class="clear-block">

      <div id="header">
        <div id="logo-floater">
        </div>
        ...
        ...

      </div> <!-- /header -->
      ...
      ...

    </div> <!-- /container -->
  </div>
<!-- /layout -->

and in style.css

#wrapper {
  background: #edf5fa url(images/body.png) repeat-x 0% -37px;
}

Comments

beautifulmind’s picture

Well, if you like to do some coding in your page.tpl.php, I can suggest some fixes.
You can check the user roles and set the background image accordingly. Like as follows:

if ($user->uid > 0 && and $user->uid != 1) { // here 0 for anonymous and 1 for admin
   //now the user is an authenticated user...so...assign the image for authenticated user
}
elseif ($user->uid ==0) {
 //assign for anonymous user...
}

You can also check the roles as well.

Hope this will help you.

Thank you.

Beautifulmind
Know more

Regards.
🪷 Beautifulmind

Iumentum’s picture

I think the easy way is to give the #wrapper a class so you so something like this:

<div id="wrapper" class="<?php echo (user_is_logged_in()) ? 'class_for_authenticated' : 'class_for_anonymous'; ?>">
beautifulmind’s picture

yeah, that can be an alternative to some tedious coding. sort and sweet!

Beautifulmind
Know more

Regards.
🪷 Beautifulmind

magnus’s picture

Thanks for quick responses both of you!

I used <div id="wrapper" class="<?php echo (user_is_logged_in()) ? 'class_for_authenticated' : 'class_for_anonymous'; ?>">

I tried this in my style.css but that doesn't work.

#wrapper .class_for_anonymous {
  background: #fbf9f2 url(images/front.png) repeat-x 0% -37px;
}

#wrapper .class_for_authenticated {
  background: #fbf9f2 url(images/body.png) repeat-x 0% -37px;
}

Need to learn some CSS I guess =)

magnus’s picture

Been a while since I tried this. Today I did some trial-and-error and found out why it didn't work.
If someone else wants to know how to handle this I used this in my style.css:

#wrapper.class_for_anonymous {
  background: #fbf9f2 url(images/front.png) repeat-x 0% -37px;
}

#wrapper.class_for_authenticated {
  background: #fbf9f2 url(images/body.png) repeat-x 0% -37px;
}