PDA

View Full Version : Real-time Logo Graphic Changes in vB 3.7.4 ?


JamesC70
12-28-2008, 01:27 AM
Okay.... for New Year's I want to display a dropping ball (similar to the New York City event) on my forum in place of the forum logo graphic.

I've already created 61 seperate logo images, with the appearance of the ball dropping down, and uploaded them to the server. I've also written a little PHP file that will display the files in order once we're one minute away from New Year 2009. (Logo 60 is the ball at full height, as we get closer to 0 the ball "drops", and Logo 0 is the ball completely down with the words "Happy New Year" above.)

However, I'm totally stuck on getting the PHP to work within the vB header template. It seems that no matter how I encapsulate the <if> conditionals, the logo variable isn't actually assigned. In addition, the line below that displays the number of seconds til 2009 displays code instead of the variable's value.

Here's the PHP code to determine which logo to display:
<?php
$target = mktime(0, 0, 0, 1, 1, 2009) ;
$today = time () ;
$difference =($target-$today) ;
$seconds =(int) ($difference) ;
if ($seconds < "0" ) { $seconds = "0"; }
if ($seconds < "60" ) { $logo = "http://(websitename).com/images/nye/mm-logo-ny$seconds.png"; }
else { $logo = "http://(websitename).com/forums/images/mm-logo-black-480x110.png"; }
?>

... and here's the PHP code to actually display the header graphic:
<!-- logo -->
<a name="top"></a>
<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td align="center">
<?php
print "<img src=\"$logo\" border=\"0\" /><br />";
if ($seconds < 61)
{ if ($seconds > 0)
{ print "$seconds seconds remaining til New Year 2009!</td>"; }
else
{ print "</td>"; }
}
?></tr></table>
<!-- /logo -->

(And yes, I did try to use $stylevar[titleimage] instead of $logo when I was in the vB template.)

Any ideas? Is this even possible in vB 3.7.4? :confused:

Attitude5ire
12-28-2008, 08:29 AM
I would recommend to use a Flash option and this solution is much easier in fancier with Flash.

JamesC70
12-28-2008, 03:34 PM
Will Flash detect the time of day from the server and automatically adjust the logo as appropriate?

What I'm trying to accomplish is for the forum to appear normal until one minute before midnight on January 1, but these images (or a single Flash animation) to appear during the one-minute countdown.

Once New Year's Day has arrived, I don't mind the finished screen with "Happy New Year!" staying for a few hours or until I revert back to default style. (I am currently using a clone of the default style for this project.)

The intent is to free me up so that I don't actually have to be on the forum to swap the style just before midnight. We have computers that can adjust things based on date and time of day, I want to be able to do that. ;)

Attitude5ire
12-28-2008, 07:19 PM
You can have UTC universal timezone. So it acts whatever you what to do during that time.. If you go by local pc time which is not favourable as there might be different timezone people in your board. Just go with universal timezone it should be easy to do.

JamesC70
12-28-2008, 09:04 PM
I ended up putting it in an IFRAME, and adding a META REFRESH. For anyone else who wants to do something similar, here's the new code:

Header Template Within vBulletin: (Red is the part to review or change to suit your needs.)
<!-- logo -->
<a name="top"></a>
<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
<tr><td align="center"><iframe src="http://(websitename).com/countdown.php" height="270" width="500" frameborder="0"></iframe></td></tr></table>
<!-- /logo -->
<!-- content table -->
$spacer_open
$_phpinclude_output



Revised PHP code (countdown.php):
<?php
$target = mktime(0, 0, 0, 1, 1, 2009) ;
$today = time () ;
$difference =($target-$today) ;
$seconds =(int) ($difference) ;
if ( $seconds < "0" ) { $seconds = "0"; }
if ($seconds < 60) {
$logo = "http://(websitename).com/images/nye/mm-logo-ny$seconds.png" ;
}
else
{
$logo = "http://(websitename).com/forums/images/mm-logo-black-480x110.png" ;
}
?>
<html><head><style type="text/css">
body
{ background: #000000; color: #ffffff; font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin: 0px 0px 0px 0px; padding: 0px; }
</style>
<?php if ($seconds < 90) { if ($seconds > 0) {print "<meta http-equiv=\"refresh\" content=\"1\">"; } } ?>
</head>
<body>
<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
<tr><td align="center"><?php print "<img src=\"$logo\" border=\"0\" alt=\" \" /><br />";
if ($seconds < 90)
{ if ($seconds > 0)
{ print "$seconds seconds remaining til New Year 2009!</td>"; }
else
{ print "</td>"; }
}
?></tr></table>
<!-- /logo -->
</body>
</html>


Using the above code:

- Set the mktime function to the end of countdown (hours, minutes, seconds, month, day, year). You may need to adjust this for your server's timezone. If you want to display New Year's in Denver but your server is on New York time, set the mktime function for (2, 0, 0, 1, 1, 2009), which would instead trigger for 2am New York, which is Midnight in Denver.

- The "if $seconds < 90" starts refreshing the IFRAME, and displaying a countdown, roughly 30 seconds before the custom New Year logo graphics start appearing. I didn't want to go through all this work and nobody notice them. Adding the countdown seemed to be a quick way to get viewers' attention. ;)

- The "if $seconds > 0" bit of code stops the refresh once we hit end of countdown, and also stops displaying the "__ seconds til New Year" line below the logo graphic.

My forum sees about a thousand uniques per day, and I only expect to see 20 people or so when this would be active, so the timing works for my server. If you have a busy forum, you might need to adjust the $difference calculation in the PHP code to account for lag time.