News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Background Image/Color Changer

Started by - = Orfeo = -, October 27, 2009, 05:06:08 PM

Previous topic - Next topic

Arantor

You need to tell me what you want before I can make it for you.

- = Orfeo = -

Thanks Arantor! but someone did it work?

  $context['html_headers'] .= '<style type="text/css">body { background-color:' . $color . '; }</style>';

Really this work fine?

I make this modification but don't work too:

function loadTimeColor()
{
  global $context;
  if(empty($context['html_headers']))
    $context['html_headers'] = "";
  $hour_block = date('H', forum_time());
{
if ($hour_block < 6)
      $color = 'black';
elseif ($hour_block < 7)
      $color = '#ff0000';
elseif ($hour_block < 12)
      $color = 'green';
elseif ($hour_block < 18)
      $color = '#ea00e7';
elseif ($hour_block < 22)
      $color = 'violet';
elseif ($hour_block < 24)
      $color = '#AA0000';
  }
  $context['html_headers'] = '<style type="text/css">body { background-color: ' . $color . '; }</style>';
  // this should work because an inline style is supposed to override one from a style sheet
}


It's only a example, should work?  :(

Arantor

I did say I hadn't tested it. Take a backup or have a local installation, and test it on that.

- = Orfeo = -


Arantor

Anything in the error log?

And if you view the source of the page do you see that new tag?

- = Orfeo = -

Quote from: Arantor on October 29, 2009, 12:32:52 PM
Anything in the error log?

And if you view the source of the page do you see that new tag?

These codes are not modify the body background-color value  :(

Arantor

That wasn't what I asked.

Is there anything in the forum error log?

And if you view the HTML source, do you see the new tag added into the <head> ?

- = Orfeo = -

Quote from: Arantor on October 29, 2009, 12:37:30 PM
That wasn't what I asked.

Is there anything in the forum error log?

And if you view the HTML source, do you see the new tag added into the <head> ?

I don't see a new tag or the forum error log

Arantor

Can I have a link to your forum please?

- = Orfeo = -

#49
ops  :P

- = Orfeo = -

I send you the forum in a PM, but the code don't working Arantor  :(

Arantor

I've seen the PM, I will investigate shortly.

- = Orfeo = -


Arantor

I've looked at your forum.

Even if the code worked and output the correct headers, which it isn't, it wouldn't work anyway since the theme you have has a background image which would override a background colour.

In any case the boards themselves should have a different background colour so the text would be legible against the changing master background.

- = Orfeo = -

Quote from: Arantor on October 29, 2009, 08:20:23 PM
I've looked at your forum.

Even if the code worked and output the correct headers, which it isn't, it wouldn't work anyway since the theme you have has a background image which would override a background colour.

In any case the boards themselves should have a different background colour so the text would be legible against the changing master background.

Thanks Arantor, but i have some questions:

$context['html_headers'] .=

The "." is necessary?

I put the function in index.php, is correctly? in any case in index.template.php??

The image are no problem, i use "background" as "background-color", the modification only touch the "background-color", then no affect the image (The redeable texts are no problem).

aunque
       
How is it the correct headers?  :o

Arantor

The . is necessary, yes. It means add on to the end. But it's not just a case of putting the function loadTimeColor() in. You also have to put the other call in as well.

Oh, and background-image *overrides* background-color. You have a background image specified. You can change background-color all you like; it wont' do anything except when the picture hasn't loaded.

And, right now as per that link, the board layout is transparent. I see the background image behind the board text. It will NOT be readable properly with the colours you've specified.

- = Orfeo = -

Quote from: Arantor on October 29, 2009, 09:05:24 PM
The . is necessary, yes. It means add on to the end. But it's not just a case of putting the function loadTimeColor() in. You also have to put the other call in as well.

Oh, and background-image *overrides* background-color. You have a background image specified. You can change background-color all you like; it wont' do anything except when the picture hasn't loaded.

And, right now as per that link, the board layout is transparent. I see the background image behind the board text. It will NOT be readable properly with the colours you've specified.

Yes, about the transparency the text is no problem.
About the background and background-color in "background" i have assigned the image, and "background-color" the color (grey).

I searching on the web, and a easy solution is by java  :o

Arantor

*shrug* You can do it quite happily in Javascript too. I'm not so much a Javascript person (which is frightening since my current 'big' project is a massive AJAX application)

Yahmez

Quote from: tintin16 on October 29, 2009, 09:16:26 PM
Quote from: Arantor on October 29, 2009, 09:05:24 PM
The . is necessary, yes. It means add on to the end. But it's not just a case of putting the function loadTimeColor() in. You also have to put the other call in as well.

Oh, and background-image *overrides* background-color. You have a background image specified. You can change background-color all you like; it wont' do anything except when the picture hasn't loaded.

And, right now as per that link, the board layout is transparent. I see the background image behind the board text. It will NOT be readable properly with the colours you've specified.

Yes, about the transparency the text is no problem.
About the background and background-color in "background" i have assigned the image, and "background-color" the color (grey).

I searching on the web, and a easy solution is by java  :o

Perhaps you could change your images to .png and make them semi transparent so the bg color shows through?

- = Orfeo = -

Guys! i make it!!!  :D

It's very simple, only change the index.template.php:
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';


For this:
   $hour_block = date('H', forum_time());
if ($hour_block < 6)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
elseif ($hour_block < 7)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style2.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
elseif ($hour_block < 12)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style3.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
elseif ($hour_block < 18)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style4.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
elseif ($hour_block < 22)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style5.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
elseif ($hour_block < 24)
echo'
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style6.css?fin11">
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';
;


Obviously, you need to create (or copy/paste) de "style.css" (in this case the second copy is "style2.css", third copy is "style3.css"....) and change the values to modify, then you can modify ANYTHING  ;D

This simplify all (even if you know something of css), in this example are six changes, but changing the "$hour_block < x" you can modify and extend or minimize de changes, ENJOY IT!  ;D

Advertisement: