') ') Fork me on GitHub

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $10.00
Net Balance: $9.41
Left to go: $90.59

Donations
Dante7237  ($10)Dec-3

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 4 6 adslight Android AntiHarvesting AntiSpam API Apple Battlefield billige Bootstrap Captcha cell cent chronolabs CHUNG Clicks content CĂN demo docek download Dresses evden eve facebook Fat floor for free Gateway giải Google Guide herre Home Honeypot Human HỘ IP iPhone jQuery Language Law Legal List log Loss module modules Monster new newbb news nhiệt NHÀ online PARK Payment phone PHP Prevention profile project Protector publisher RESIDENCE responsive review Rights rmcommon security Sentry Signatures Signed site Smartphone Smoking Solution Spam stem Studio tdmcreate template The Theme themes tháp web weight xoops Xortify XPayment ZendFramework

New Users

Registering user

# 137911

mydarkglobe

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  |  Register To Post



#1 Posted on: 2010/8/15 7:31 How to change css depending on the time??
Hello,

First, apologize for my English hehe.

I'm trying to change the css of a theme depending on time of day. I entered the following code on theme.html but I get errors.
Someone could help me?

<link rel="stylesheet" type="text/css" media="all" href="
<?php  $hour date('H');  
if ((
$hour >= 6) and ($hour <= 19))  
{
echo 
"<{$xoops_imageurl}>css/blue.css"
}  
else  
{     
echo 
"<{$xoops_imageurl}>css/red.css"
?> 
" />


I tried to do work in several ways, but I can not.

Thank you very much for your time.

Top

faucess
Joined:
2010/4/26 13:25
Group:
Registered Users
Posts: 2
(Show More) (Show Less)


#2 Posted on: 2010/8/15 8:44 Re: How to change css depending on the time??
Hello,

Interesting idea, change the theme depending on time of day.

Although I do not know how you would do this in PHP I have found a javascript which may do it.

<SCRIPT LANGUAGE="JavaScript">
<!-- 
Begin
function getCSS()
{
datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour datetoday.getHours();

if (
thehour 20)
display "tree_twilight.css";
else if (
thehour 17)
display "tree_sunset.css";
else if (
thehour 14)
display "tree_afternoon.css";
else if (
thehour 11)
display "tree_noon.css";
else if (
thehour 7)
display "tree_morning.css";
else if (
thehour 4)
display "tree_sunrise.css";
else if (
thehour 1)
display "tree_twilight.css";
else
display "tree_sunset.css";

var 
css '<';  css+='link rel="stylesheet" href=' display ' /';  css+='>';

document.write(css);
// End -->
}
</script>
<script language="javascript">getCSS();</script>


The code is from this website http://www.katgal.com/2007/03/time-se ... -css-switcher-change.html.

I hope you get it working.

Top

playsome
Joined:
2009/4/15 15:38
Group:
Registered Users
Posts: 197
(Show More) (Show Less)


#3 Posted on: 2010/8/15 9:04 Re: How to change css depending on the time??
Great!

It works perfectly, thank you very much! You took the headache of several days hehe.

Greetings!

Top

faucess
Joined:
2010/4/26 13:25
Group:
Registered Users
Posts: 2
(Show More) (Show Less)







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create pdf.
You cannot get print page.

[Advanced Search]