Fork me on GitHub
Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Nominate XOOPS!

Learn XOOPS Core

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $25.00
Net Balance: $23.97
Left to go: $76.03

Donations
Anonymous ($25)Aug-11

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 4 6 Abuse adslight Android AntiHarvesting AntiSpam API Apple Battlefield billige Blocks Bootstrap Captcha cell cent chronolabs CHUNG Clicks content CĂN demo download Dresses evden facebook Fat floor for free Gateway Google Guide herre Home Honeypot HP html5 Human HỘ iPhone jQuery Language List log Loss module modules Monster new newbb news NHÀ online PARK Payment phone PHP Prevention profile project Protector publisher RESIDENCE responsive review Rights rmcommon Room security Sentry site Smartphone Smarty Smoking Spam stem Studio support tag tags tdmcreate template The Theme themes User userlog web weight xoops Xortify XPayment ZendFramework

New Users

Registering user

# 137682

jrmybell

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
Just popping in
Just popping in
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
Not too shy to talk
Not too shy to talk
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
Just popping in
Just popping in
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.

[Advanced Search]