Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

How to use date + time to control modules returned

How to use date + time to control modules returned

Hi guys!

first of all... what a great product as I'm sure you've heard it before!

environment:

joomla: 1.5.22
php:     5.2.14
metamod: 2.6 Nov 29/2010

current recipe

if ( MM_DAY_OF_WEEK == 1 ) return 160;
// chunkyfunky live

if ( MM_DAY_OF_WEEK == 2 ) return 162;
// retarded beats

if ( MM_DAY_OF_WEEK == 3 ) return 161;
// djhawkie live

if ( MM_DAY_OF_WEEK == 4 ) return 169;
// iTrecklass

if ( MM_DAY_OF_WEEK == 5 ) return 170;
// dj DJArael

if ( MM_DAY_OF_WEEK == 6 ) return 166;
// ill House Saturdays

if ( MM_DAY_OF_WEEK == 7 ) return 167;
// DYDyno

whats happening:  this recipe looks at the date and then based on what day of the week, it shows a particle module.  So there are 7 modules I show.  I want that to change to 28 and have 4 on each day.

1) Can I make it more granular and have 4 modules for each day.  So module #1 returned 0-6hrs, module #2 7-12hrs, module #3 13-18hrs and module #4 19-24hrs.  Then the next day starts and 4 new modules use the same pattern.  So on and so on for the rest of the week.

2) Should I be using elif for this?


Thanks,
Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: How to use date + time to control modules returned

and right now also, when the week is over, the module stops displaying anything at all.

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: How to use date + time to control modules returned

anyone?

can I do:

if ( MM_DAY_OF_WEEK == 7 && $core_genius->inTimeSpan( "00:00:00 - 05:59:59" ) ) return 167;
if ( MM_DAY_OF_WEEK == 7 && $core_genius->inTimeSpan( "06:00:00 - 11:59:59" ) ) return 168;
if ( MM_DAY_OF_WEEK == 7 && $core_genius->inTimeSpan( "12:00:00 - 15:59:59" ) ) return 169;
if ( MM_DAY_OF_WEEK == 7 && $core_genius->inTimeSpan( "16:00:00 - 23:59:59" ) ) return 170;

to get it to cycle through 4 modules for the day?


Thanks,
Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: How to use date + time to control modules returned

Hi tokenring,

First up, Sunday is day 0, not day 7. That's why your rule seemed to fail on Sunday smile

There are a number of ways to do the time of day thing. I'll show you how to do it with a combination of the day of week constants and the JomGenius time period support.

if ( MM_DAY_OF_WEEK == 1 ) {
  if ( $core_genius->inTimeSpan("00:00 - 05:59:59") ) return 1;
  if ( $core_genius->inTimeSpan("06:00 - 11:59:59") ) return 2;
  if ( $core_genius->inTimeSpan("12:00 - 17:59:59") ) return 3;
  if ( $core_genius->inTimeSpan("18:00 - 23:59:59") ) return 4;
}

if ( MM_DAY_OF_WEEK == 2 ) {
  if ( $core_genius->inTimeSpan("00:00 - 05:59:59") ) return 5;
  if ( $core_genius->inTimeSpan("06:00 - 11:59:59") ) return 6;
  if ( $core_genius->inTimeSpan("12:00 - 17:59:59") ) return 7;
  if ( $core_genius->inTimeSpan("18:00 - 23:59:59") ) return 8;
}
// ... etc.

You can learn more about JomGenius inTimeSpan here: http://www.metamodpro.com/jomgenius/parameters
Finally, yes you can use elif, but there's no gain in doing so here, since the code is doing a "return" and doesn't even make it to the next line.

Hope that helps,
Stephen

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

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

Re: How to use date + time to control modules returned

... looks like we were both replying at the same time... so yes, I think that's a good plan.

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

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

Re: How to use date + time to control modules returned

thanks stephen!  not sure how I got the days mixed up when all other modules seemed to show up on their correct day.  this is an excellent module and I might just upgrade.

Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: How to use date + time to control modules returned

Hi metamodguy ,

let me know how can i play audio songs on date and time schedule

For Example my Requirement is As follows:

Schedule 1 every   Saturday-->5am to 7 am: songs 1,2,3,4,5
Schedule 2 every   sunday -->5am to 7 am: songs 100-120
Schedule 3 every   Monday-friday -->5am to 7 am: songs 120-150
Schedule 4 -->7am to 1 pm: songs 1-20
Schedule 5-->1pm to 5 pm: songs 20-50
Schedule 6-->5pm to 10pm: songs 50-75
Schedule 7-->10pm to 12am: songs 75-100

i installed metamod and i left the time zone as default(my country is india)

for testing purpose i want to play the songs on the present day
4:00pm to 6:00pm
I written the code in php Block as below

if (MM_TIME >= 165500 && MM_TIME <= 175500) return 142;

But it is not displaying play list module.

please let me know how can i play playlist on time schedule(according to week,month,and time)

Please kindly letme know the solution.

                                 Thank You

bharath
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: How to use date + time to control modules returned

Hi Bharath,

I think it's probably a basic setup issue. Please ensure the MetaMod is published, in a valid module position for your template, and set to display on some or all pages. If that doesn't work, turn on MetaMod debug mode and ensure that you see some output on every page that the MetaMod is assigned to.

Your PHP code seems fine. Please write back if you need any help with the other time constraints (though if you know PHP it's fairly simple).

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

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

Board Info

Board Stats:
 
Total Topics:
1438
Total Polls:
6
Total Posts:
5118
Total Posts Today:
1
User Info:
 
Total Users:
4674
Newest User:
Belositres
Members Online:
0
Guests Online:
71

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