News:

Wondering if this will always be free?  See why free is better.

Main Menu

Background Image/Color Changer

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

Previous topic - Next topic

- = Orfeo = -

Quote from: Arantor on October 28, 2009, 09:17:07 PM
When I said about helping I always mean in public where the same advice may help someone else.

First of all, figure out exactly how you want it to work. Then we need to look at your theme and work out what needs to be changed over time, and whether you need to get the designer to make you new images. (Unfortunately, no, it's not as simple as just changing a few numbers)

Mmm.... i need only change the body values:

body
{
background:


Or the class:

Quotebody
{
   background:...}

body2
{
   background:}

   
depending on the time:

date('H', forum_time())

;D

Arantor

How often? Every hour? Every 2 hours?

As for the background, that is literally the area outside the forum. It depends VERY much on your theme which is why I would need to know what theme you're using or even to see your site to tell whether that would actually be very effective or not.

On this forum, changing that value would have NO effect at all, since the body background is that gradient.

- = Orfeo = -

Quote from: Arantor on October 28, 2009, 09:29:38 PM
How often? Every hour? Every 2 hours?

As for the background, that is literally the area outside the forum. It depends VERY much on your theme which is why I would need to know what theme you're using or even to see your site to tell whether that would actually be very effective or not.

On this forum, changing that value would have NO effect at all, since the body background is that gradient.

Hahaha! no!  :P

I like 6 changes (every 4 hours), i have SMF 1.1.10 and Default Theme without modifications.

i need the modifications at least,    i usually alter mods,    
I thought something like that (Greeting Time Mod - load.php):

   
// Load a custom greeting
function loadGreeting()
{
global $context, $txt, $modSettings;


$date = date('H', forum_time());

if ($date < 6)
   $greeting = !empty($modSettings['cgdt_message1']) ? $modSettings['cgdt_message1'] : $txt['up_late_arent_we'];
elseif ($date < 7)
    $greeting = !empty($modSettings['cgdt_message2']) ? $modSettings['cgdt_message2'] : $txt['are_you_the_early_bird'];
elseif ($date < 12)
   $greeting = !empty($modSettings['cgdt_message3']) ? $modSettings['cgdt_message3'] : $txt['good_morning'];
elseif ($date < 18)
   $greeting = !empty($modSettings['cgdt_message4']) ? $modSettings['cgdt_message4'] : $txt['good_afternoon'];
elseif ($date < 22)
   $greeting = !empty($modSettings['cgdt_message5']) ? $modSettings['cgdt_message5'] : $txt['good_evening'];
elseif ($date < 24)
   $greeting = !empty($modSettings['cgdt_message6']) ? $modSettings['cgdt_message6'] : $txt['shouldnt_you_be_going_to_bed_soon'];


But with the body  :o

Arantor

Well, like I said I need to know the forum theme before I can begin to suggest how to do this.

- = Orfeo = -

Quote from: Arantor on October 28, 2009, 09:51:15 PM
Well, like I said I need to know the forum theme before I can begin to suggest how to do this.

Is a Default Theme   ;D

Arantor

So you want it to do purely the background and not any of the areas on it? Note that this could make the linktree hard to read if not careful.

Yahmez

Thank you for explaining publicly Arantor.

*Yahmez watches with interest

- = Orfeo = -

Quote from: Arantor on October 28, 2009, 10:06:12 PM
So you want it to do purely the background and not any of the areas on it? Note that this could make the linktree hard to read if not careful.

Yes! May be the #userarea, #news, windowbg and windowbg2, the color in all (black to white), but I think this last I can do  :)

Arantor

windowbg and windowbg2 use images, by the way... as does #news and possibly #userarea (I don't get into the theme that much to be honest)

- = Orfeo = -

Quote from: Arantor on October 28, 2009, 10:30:07 PM
windowbg and windowbg2 use images, by the way... as does #news and possibly #userarea (I don't get into the theme that much to be honest)

   
I plan on making in a future a transparent background which includes the # userarea, without images (these are the user data on top).

Windowbg and windowbg2 colors are the tables text, for this i wish to change the colours  ;D

Arantor

If you make them fully transparent, you get just an outline and inherit the background colour.

And technically, windowbg and windowbg2 styles cover both the foreground text colour and background image for many, many things across the forum.

- = Orfeo = -

In windowbg and windowbg2 the background should be transparent, while the colors are solids (this way are the background are transparent, while the text have the solid color).

I don't like use the opacity, only this features (background-color and color) for css  :)

- = Orfeo = -

Quote from: tintin16 on October 28, 2009, 10:51:55 PM
In windowbg and windowbg2 the background should be transparent, while the colors are solids (this way are the background are transparent, while the text have the solid color).

I don't like use the opacity, only this features (background-color and color) for css  :)

I know that the secret it's on (ex.):

index.template.php
<body class="body2">

in css
body{blablabla}

.body2 {blablabla}


and
$date = date('H', forum_time());

But i don't know how ranged the class  :-[

qubbah


Arantor

Quote from: tintin16 on October 29, 2009, 01:25:26 AM
But i don't know how ranged the class  :-[

Don't change the class, it isn't necessary.

Put loadTimeColor() in the same place in index.php where that mod adds loadGreeting(), then have the following in Load.php or Subs.php (doesn't really matter much)

You can remove all the stuff starting with // (as these are just comments) and change the colours to suit. NB not tested.

function loadTimeColor() {
  global $context;
  if(empty($context['html_headers']))
    $context['html_headers'] = "";

  $hour_block = round(date('H', forum_time()) / 4);
  switch($hour_block) {
    case 0: // 00:00 and 24:00 should have the same colour since they're the same time
    case 6:
      $color = '#000000'; // black for midnight
      break;
    case 1:
      $color = '#008080'; // medium blue for sunrise
      break;
    case 2:
      $color = '#00ffff'; // bright blue for morning sun
      break;
    case 3:
      $color = '#ffff00'; // bright yellow for midday sun
      break;
    case 4:
      $color = '#a05000'; // orange for evening
      break;
    case 5:
      $color = '#603000'; // brown for setting sun
      break;
  }
  $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
}

qubbah

Quote from: Arantor on October 29, 2009, 04:59:58 AM

Put loadTimeColor() in the same place in index.php where that mod adds loadGreeting(), then have the following in Load.php or Subs.php (doesn't really matter much)

You can remove all the stuff starting with // (as these are just comments) and change the colours to suit. NB not tested.

function loadTimeColor() {
  global $context;
  if(empty($context['html_headers']))
    $context['html_headers'] = "";

  $hour_block = round(date('H', forum_time()) / 4);
  switch($hour_block) {
    case 0: // 00:00 and 24:00 should have the same colour since they're the same time
    case 6:
      $color = '#000000'; // black for midnight
      break;
    case 1:
      $color = '#008080'; // medium blue for sunrise
      break;
    case 2:
      $color = '#00ffff'; // bright blue for morning sun
      break;
    case 3:
      $color = '#ffff00'; // bright yellow for midday sun
      break;
    case 4:
      $color = '#a05000'; // orange for evening
      break;
    case 5:
      $color = '#603000'; // brown for setting sun
      break;
  }
  $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 this onle we must change/add?

Arantor

If you make both the edits I mention there, yes that should be enough.

qubbah

very very niceeee.. hehe.. so good..

but can we change it every minutes?

Arantor

Depends. Sure the code can be rewritten to do that but is set to every 4 hours in the above.

qubbah

Quote from: Arantor on October 29, 2009, 05:25:56 AM
Depends. Sure the code can be rewritten to do that but is set to every 4 hours in the above.
nice to hear... will wait for that.. tq

Advertisement: