Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

is this right for date and time config?

is this right for date and time config?

Hi, I'm trying to display 1 module at  a specific time and date range and another in it's place at other times.

if ( MM_TIME >= 070000 && MM_TIME <= 170000 && MM_DAY_OF_WEEK >=1 && MM_DAY_OF_WEEK <= 3) 
return 116;
else return 150;

if ( MM_TIME >= 070000 && MM_TIME <= 230000 && MM_DAY_OF_WEEK >=4 && MM_DAY_OF_WEEK <= 5) 
return 116;
else return 150;

if ( MM_TIME >= 070000 && MM_TIME <= 150000 && MM_DAY_OF_WEEK >=6 && MM_DAY_OF_WEEK <= 0) 
return 116;
else return 150;



The reason I ask if this is right or not, is because today (Thursday)the module did not change at 7am like it was supposed to.

jcmyers
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: is this right for date and time config?

Hi JC,

The PHP interpreter will run through each line of the PHP code in turn, and evaluate it. If it reaches a "return" statement, then it will exit the PHP, and return the corresponding value to MetaMod.

Therefore your "else return 150;" statements are going to prevent the 2nd and 3rd rules from even being evaluated.

So I'd write the rule like this:

if ( MM_TIME >= 070000 && MM_TIME <= 170000 && MM_DAY_OF_WEEK >=1 && MM_DAY_OF_WEEK <= 3) 
return 116;
if ( MM_TIME >= 070000 && MM_TIME <= 230000 && MM_DAY_OF_WEEK >=4 && MM_DAY_OF_WEEK <= 5) 
return 116;
if ( MM_TIME >= 070000 && MM_TIME <= 150000 && MM_DAY_OF_WEEK >=6 && MM_DAY_OF_WEEK <= 0) 
return 116;
else return 150;

So the way I interpret this, is:
- between 7AM and 5PM, Monday to Wednesday, show 116
- between 7AM and 11PM Thursday and Friday, show 116
- between 7 AM and 3PM Saturday and Sunday, show 116
- at all other times, show 150.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: is this right for date and time config?

Awesome! Works perfectly! Thank You!

jcmyers
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: is this right for date and time config?

I have another module thats having issues with, this module needs to show module A (165), Monday - Sunday between 10:30 AM to 3:00 AM and then show module B (166) at all other times.

if (MM_TIME >= 103000 and MM_TIME < 030000) return 165;
else return 166;

This doesn't seem to work and also causes the module not to switch at 10:30 AM in the morning.

jcmyers
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: is this right for date and time config?

Hi JC,

the main reason it doesn't work is because of a quirk of PHP - if you put "0" in front of a number it interprets it as an Octal (base 8) number. So, for 3AM, use 30000, not 030000.

The other reason is that the time can never be after 10:30 and before 03:00... in terms of the numbers. So it needs to be less than 30000 (i.e. between midnight and 3AM) OR greater than 103000 (from 10:30 AM until midnight).

Therefore:

if (MM_TIME >= 103000 or MM_TIME < 30000) return 165;
else return 166;


Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: is this right for date and time config?

lol i had tried 300000 too

Thanks for your help and quick response!

jcmyers
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Total Posts Today:
1
User Info:
 
Total Users:
10075
Newest User:
rsker57
Members Online:
0
Guests Online:
263

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked