Hello,

So far I have managed to get most things done on my own, but here I am stuck and I can't seem to find another topic with the answer...

I would like to restrict my background image to logged-in users only? I am sorry to ask for a swift answer but my web site has to go live and it is the last thing I have to do...

Help!

I would so greatfull if someone can redirect my or answer my question... :-)

Comments

rentex’s picture

The easiest would be if you'd use 2 themes:
|: Theme that logged in users can see
2: Theme that non-logged in users can see (it can be the very same theme, the only difference here would be the lack of that background image).

In Admin ===>>>> Themes choose a themes as your default theme (the default theme is the theme displayed when accessing the website as anonymous user). Just enable the other theme, and go to everybodies account and set that new theme as their default.

In the CSS just remove the line that sets the background image in the theme that was intended for non-logged in users.

saabman’s picture

Thanx for that I hadn't thought of that!

Can you just tell which line needs to be removed?

Thanx again!!!
:-)

rentex’s picture

Where exactly is that image: for example - the background in the main content area (in what theme, Drupal version)?
Maybe post a screenshot, if you don't find the right words.

saabman’s picture

OK first before I start with removing the css lines, I encountered some trouble to duplicate my theme,

I almost crashed the site ;-) how should I go about duplicating my current and only theme? I can't just copy it as this brings up a load of conflicts...

For the css editing I have the standard 'chameleon' theme currently in it's default config. So the location of the background is .../themes/chameleon/background.png

Thanx for you help ;-)

rentex’s picture

Do you really have to use the chameleon theme?

That would result in being a bit more complicated yeah. Do you have any PHP-programming knowledge?
Because if you want to duplicate a theme like chameleon, you've got to rename all functions in one of themes, as it is not possible to have the same function names twice. This you'd have to do in the file named: chameleon.theme.

If you'd be using a theme that is powered by any template-engine you'd not need to do this (at least not in PHPtemplate as far as I know, check this out if you're going to use other engine powered themes).

Actually I could easily explain how this should be done: it's very easy and takes at most 5 minutes.

saabman’s picture

rentex,

I tried something that seems to work, tell me if you think this is ok:

I created a file in the chameleon main theme file and just popped the style.css into it and changed it, seems to add a theme that takes up all the chameleon functions but is considered as a seperate theme, I noticed this because the marvin theme seems to work like that too...

The only problem I face now is that I would need every thing (name of site, slogan, nodes,etc) to start a bit lower down on the page and set the width od everything to 800px, I guess there are some lines I need to change...

All I can say is you really helped me out today!!!
Thanx :-)

saabman’s picture

Rentex,

OK I have found in the mean time! It all works, great help, Drupal is just great!!!

;-)

Thanx yet again for your help!

dtabach’s picture

If the only difference is the background image, you'd better use only one theme, avoiding a lot of redundant resources; and apply different css styles - with and without background - depending on the user status.
You should have a PHP theme, and add something like this in your page.tpl.php or node.tpl.php, or another tpl.php file (depending on where you want your background):

<?php
global $user; 
if (!$user->uid) {print "<div id='style_with_background'>";}
  else {print "<div id='style_without_background'> ";
?>
<p>Your html goes here.<p>
</div>

This way you will not have to manually change the theme for every new user that registers to the site.

Durval Tabach

saabman’s picture

Thank you all for your help in this matter, I don't have that many users and I ran an SQL query to change there themes... seems to have worked fine, of course it isn't the cleanest of solutions but I was in a hurry... I will get it better later when I have some more time.
:-)