Plugin:  Count-up & Countdown
Posted: 04 March 2008 10:16 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008

Hello everyone,

I just expanded on Steve Sharpe’s Timesince plugin to include some additional functionality.

This plugin maintains the functionality that is in Steve’s plugin and expands to include future dates.  I needed something to show how much time remained until certain dates for an events page so this works great for that.

By default, it gives the following output (depending on how much time there since/until the date):

Dates that have passed:
25 minutes ago
2 hours, 1 minute ago
6 days, 8 hours ago
3 months, 11 days ago
2 years, 3 months ago

Dates to come:
25 minutes
2 hours, 1 minute
6 days, 8 hours
3 months, 11 days
2 years, 3 months


You can use it in any entry or comment template.  The basic syntax is this:

[/code]{exp:count_time:standard}
{entry_date}  
or  {comment_date}
{
/exp:count_time:standard}


Additionally, there are two optional parameters that can be passed to the function.
(1) seperator - The “seperator” parameter controls the character which appears between each unit.  This is set to be a comma by default.
(2) ending -  the “ending” paramter controls what appears at the end of the date.  This is set to be ago by default for dates that have passed and blank for dates to come.

For example,

{exp:count_time:standard seperator="and" ending="have elapsed."}
{entry_date}  
or  {comment_date}
{
/exp:count_time:standard}

The above would yield:  2 hours and 1 minute have elapsed.


Lastly, there are seven other calls you can make within the {exp:count_time} tag to determine the output.

{exp:count_time:standard} outputs a two unit string (2 Months, 5 Days)

The below only output in one unit.  They also take the optional ending paramater.  The default is ago for past events and nothing for future events.

{exp:count_time:years} —>  1 year (ago)
{exp:count_time:months} —> 12 months (ago)
{exp:count_time:weeks}—> 52 weeks (ago)
{exp:count_time:days}—> 365 days (ago)
{exp:count_time:hours} —> 8,760 hours (ago)
{exp:count_time:minutes} —> 525,600 minutes (ago)
{exp:count_time:seconds}—> 31,536,000 seconds (ago)


Files are attached smile

EDIT:
Updated with Mark Bowen’s suggestion (see below).

EDIT:
Added language file

File Attachments
pi.count_time 1.1.0.zip  (File Size: 3KB - Downloads: 145)
Profile
 
 
Posted: 05 March 2008 04:36 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Hiya,

Looks like a really great addition, well done.

One of my pet peeves though is when you have something like 1 years ago. Would it be possible in singular cases such as that to get it saying 1 year ago? wink

Just a very very small thing though. I’m sure a lot of people will find this really useful so well done.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 March 2008 07:28 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Just what I was looking for.

Cheers!

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 05 March 2008 08:18 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008
Mark Bowen - 05 March 2008 04:36 AM

Hiya,

Looks like a really great addition, well done.

One of my pet peeves though is when you have something like 1 years ago. Would it be possible in singular cases such as that to get it saying 1 year ago? wink

Just a very very small thing though. I’m sure a lot of people will find this really useful so well done.

Best wishes,

Mark

I totally agree with you.  That’s one of my pet peeves too actually.  I noticed that late last night as I was about to go to sleep and didn’t have the energy to fix it. 

Now, if the value is 1, the unit will in the singular form (year, month, day, etc…).

Attached is a new version.

File Attachments
pi.count_time 1.0.1.zip  (File Size: 3KB - Downloads: 106)
Profile
 
 
Posted: 05 March 2008 08:22 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Any chance you could make this plugin use a language file so it can be localized?  cool smirk

Just keeping you busy.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 05 March 2008 09:02 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Hiya,

Sorry I hope it didn’t come across nasty when I said it was one of my pet peeves? Wasn’t meant to. Thanks for updating it, very nice indeed.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 March 2008 09:18 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008
Cocoaholic - 05 March 2008 08:22 AM

Any chance you could make this plugin use a language file so it can be localized?  cool smirk


Ummm, sure why not.  Updated version attached, with language files.

Mark Bowen - 05 March 2008 09:02 AM

Hiya,

Sorry I hope it didn’t come across nasty when I said it was one of my pet peeves? Wasn’t meant to. Thanks for updating it, very nice indeed.

Oh, don’t be silly.  I wasn’t offended at all.  You were right, it’s the details that count.


Any other suggestions/criticisms are welcome.  I only started teaching myself PHP a couple months ago and just picked up EE last week, so I’m sure there is probably a lot of room for improvement in my coding.

File Attachments
pi.count_time 1.1.0.zip  (File Size: 3KB - Downloads: 112)
Profile
 
 
Posted: 05 March 2008 09:22 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Excellent service!

Hmm, what else can we request… wink

Thanks for a great add-on.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 05 March 2008 09:56 AM   [ Ignore ]   [ # 8 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Yes… What else can we request!! wink

Just joking. You have made a great addition here so thanks for all the great work.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 06 March 2008 10:49 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

Hmm, I can use this to get some nasty PHP off of a template I’m working on. Thanks for this. One thing I might suggest has nothing to do with the plugin itself…but how it’s presented for download in a thread. This isn’t directed towards you…but to everyone, sort of, and I might make a more general post about it in another thread.

I REALLY like it when you know you can ALWAYS go to the first post in a thread to get the latest version. Sometimes threads get up to 11+ pages and if the latest version isn’t in the first thread (a convention I know Mark Huot and I use) you’re always wondering if the latest one might be on page 2…or 4…or 28… Looking back, I see that you DO have 1.1.0 in the top thread as well…my bad. But I’ll leave all this here for when some new plugin-writing person comes along.

I was also going to suggest the convention of beginning your post title with “Plugin:”, but I see you’ve already done that!

Anyway, thanks again for this!

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 05 May 2008 12:37 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
Joined  02-26-2004

Oh dear—I can think of a feature request. Sorry.

Although I think this would be expected behaviour, when you set it up as “days until” the entry, once the entry is passed, it starts counting upwards again.

So 3 days before May Day 2008 (May 1), we can get it to say “3 days until May Day 2008!”
Using the same code, on May Day 2008, it will say “1 day until May Day 2008!” (a little odd)
Using the same code, 6 days after May Day 2008, it will say “6 days until May Day 2008!”

It would be sweet if there was a way of making {exp:count_time:days} display a special message when the countdown is “zero days until” (such as ‘It’s May Day 2008!’)

...and maybe another special message if ‘after’ (ie. the days until would be negative): ‘May Day 2008 has passed.’?   

Not sure how this would be done… maybe it would have to have a parameter that would make it “aware” it is counting “time until” or “time since”?

Just trying to use this in place of a Javascript countdown script (for a group who runs a May Day website, if you couldn’t tell) wink

I’m trying to set it up so that they can re-set the countdown via a “countdown” entry, and Javascript behind the scenes wouldn’t have to be adjusted.

Thanks! This is a pretty sweet plug-in!

R o B

Profile
 
 
Posted: 05 May 2008 08:07 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008

Hmm…doesn’t the current version do that?  Oops.  I actually realized this a while ago and changed it.  I guess I forgot to upload the new version.  Sorry :-p.

I don’t have it available right now.  I try to get it up later today or tomorrow.

Profile
 
 
Posted: 06 May 2008 05:33 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-12-2008

Hi

I’ve recently discovered a bug in your plugin. For a more detailed description and how we tracked it down (Lisa and Me), please have a look at:

http://expressionengine.com/forums/viewthread/78616

Summary: the plugin somehow changes the headers sent in the 404 page. You should be able to replicate it easily, pull some weblog entries in your 404 template and add this:

{exp:count_time:standard seperator="and" ending="ago."}{entry_date}{/exp:count_time:standard}

It will change the “404” headers to “200” and break a proper “page not found” page.

Haven’t had time to go through your code, maybe you’ll take a minute.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 06 May 2008 09:33 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008

Thanks.  I have no idea why that would be happening.  I didn’t intentionally do anything with headers.  Will post with an update in a while.

Profile
 
 
Posted: 06 May 2008 09:40 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-12-2008

Yes, seems strange to mee to, i quickly went through your code and did not find any explicit header changement.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 22 May 2008 02:05 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

Just adding my thanks for this good plugin - well done grin

 Signature 

OakenPage website works - doing simple things well

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 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 42
Total Topics: 82226 Total Anonymous Users: 22
Total Replies: 441924 Total Guests: 218
Total Posts: 524150    
Members ( View Memberlist )