Cycle Through Entries Daily
Posted: 28 May 2007 10:08 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  473
Joined  09-20-2006

I have a client site where I need to cycle through about 25 different entries on a one per day basis.  In other words, I need to load one entry per day until I have exhausted the 25 entries, and then continue to repeat or cycle through that procedure.

The client wants one free song to be featured each day.

Any ideas?

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 29 May 2007 01:36 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29227
Joined  05-15-2004

Probably requires a bit of PHP. I’d take the current date, divide by 25 (or how many songs there are), take the remainder, and volia: The magic number. The rest is custom fields and a custom weblog.

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 29 May 2007 08:39 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  473
Joined  09-20-2006

Alright - I will look into it!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 29 May 2007 08:48 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  686
Joined  08-19-2006

I’d take the current date, divide by 25 (or how many songs there are), take the remainder, and volia: The magic number.

Maybe its cos its late, but how would that loop through one a day?

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 29 May 2007 09:08 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29227
Joined  05-15-2004

We don’t want to loop through one day, but get a new entry every day, then restart after 25 days. At least that’s what I understood. So, if we take, I dunno, the number of the day of the year, we’d get:

<?php echo (((date("z")+1) % 25) + 1); ?>

... effecitvely looping through 1 ... 25.

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 29 May 2007 09:14 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  686
Joined  08-19-2006

hey thats cool :D i still cant get my head around exactly whats going on there, but cool all the same…

so that is taking the day of the year, adding one, dividing by 25 and adding one to the remainder will always be one of the id’s?

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 29 May 2007 09:27 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29227
Joined  05-15-2004

Well, yes. Do you want me to break it down for you? The day of the year ranges between 0 and 365, so we add 1 (0 dividing by anything is not much fun). Today is the 148th day, so that’d be 149. Divide by 25 and keep only the remainder (“modulo operation”):

149/25 = 5, remainder 24.

Add 1, and we get 25. Tomorrow will be the 149th day, so 150/25 = 6, remainder 0, +1 = 1, we’ll start over again. Lather, rinse, repeat.

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 29 May 2007 09:32 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  686
Joined  08-19-2006

ahh wow! hey thats cool :D i should have paid more attention in maths… it would make my job so much easier :D thanks for explaining that.

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 29 May 2007 10:04 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  473
Joined  09-20-2006

Very nice!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120594 Total Logged-in Users: 69
Total Topics: 126635 Total Anonymous Users: 35
Total Replies: 665682 Total Guests: 380
Total Posts: 792317    
Members ( View Memberlist )