4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: marcus_s on April 14, 2005, 09:21:38 PM
-
hi. i like to switch the background color and other things in 4images to bright and dark by daytime (day & night).
i got this:
<?php
$hour = date(G);
if ($hour > 7 && $hour <= 20) { // von vier bis sechs
include "tag.inc";
} else if ($hour > 20 || $hour <= 7) { // zwischen 21 und vier
include "nacht.inc";
}
?>
that isn´t possible.
i got these error messages:
Warning: Unknown(nacht.inc): failed to open stream: No such file or directory in /…/gallery/includes/template.php(101) : eval()'d code on line 37
Warning: Unknown(nacht.inc): failed to open stream: No such file or directory in /…/gallery/includes/template.php(101) : eval()'d code on line 37
Warning: (null)(): Failed opening 'nacht.inc' for inclusion (include_path='.:/usr/lib/php') in /…/gallery/includes/template.php(101) : eval()'d code on line 37
what do i have to do to make it work?
thanks,
marcus
-
oh. found this now:
http://www.4homepages.de/forum/index.php?topic=4295.0
gonna try it first.
marcus
-
The code you posted will switch it based on the server's time and not the visitor. Someone half a world away sitting at their computer in full daylight will see a night theme...
-
yea i know but thats ok. my client clients are mostly german.
but im thinking about a javascript solution but i think that i need a php-script because i got some javascript-code to parse (browser-selecion). don´t think that thats gonna work with java … er 8O
the php-script wont work anyway (http://www.4homepages.de/forum/index.php?topic=4295.0) - now i got 5 error messages.
any clues?
thank you, marcus
-
Open global.php and locate this code:
//-----------------------------------------------------
//--- Generate Setting --------------------------------
//-----------------------------------------------------
$sql = "SELECT setting_name, setting_value
FROM ".SETTINGS_TABLE;
$result = $site_db->query($sql);
if (!$result) {
echo $lang['no_settings'];
exit;
}
while ($row = $site_db->fetch_array($result)) {
$config[$row['setting_name']] = $row['setting_value'];
}
$site_db->free_result();
Add after it:
$hour = date("G");
if( $hour > 7 && $hour <= 20 )
$config['template_dir'] = "day_template";
else
$config['template_dir'] = "night_template";
Where day_template is the name of the template directory that holds your daytime template, etc.
-
chris.
that sounds good to me.
so if i use your code - the 4images system will choose the template by time?
the only thing i need to do is to create a day and a night folder with the templates in it.
gonna try it.
thanks
m
-
ok. works. thanks. :)
but you're right i need a js solution to determine the client´s time. working on that.
this one´s gonna do it for now so thank you!
marcus