EllisLab text mark
Advanced Search
1 of 2
1
   
Two plugins: Time Ago, Youku EE
Posted: 07 September 2010 08:37 AM
Avatar
Joined: 2007-09-22
181 posts

Time Ago - Download

Converts past date to “1 minute ago”, “5 days ago” etc.

Usage:

{exp:channel:entries channel="news"}
{exp
:time_ago}{entry_date}{/exp:time_ago}
{
/exp:channel:entries} 

Youku EE - Download

Fetches Youku (Chinese Youtube clone) video clip information.

Usage:

{exp:youku_ee:video_info video_id="{video_id}" partner_id="{partner_id}" refresh="60"}
{swf} 
/* swf file URL */
{image} /* thumbnail */
{title}
{description}
{duration}
{date format
="%D, %F %d, %Y - %g:%i:%s"}
{
/exp:youku_ee:video_info} 

Video ID - e.g. XMjA0NDQ3MTQ4

Partner ID - e.g. XMzA0 (you need to register with Youku to get your own)

Updates:

v0.2
- Added caching: refresh=“60” will cache data for 60 minutes
- Added description: {description}

 
Posted: 07 September 2010 04:38 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-14
20504 posts

Hi, Milan - I have moved this up to Community News and removed the files.  You’ll need to host these yourselves - please see our guidelines.

Thanks!

 
Posted: 08 September 2010 06:32 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-22
181 posts

Sorry about that! I wasn’t aware that you changed the policy.

Files are now sitting in my Dropbox smile

 
Posted: 13 September 2010 06:28 PM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-11-11
635 posts

Thanks for Time Ago, very useful.

 
Posted: 19 September 2010 11:17 AM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-26
214 posts

can you advise the format date should be in to be converted ? I wish to use this in conjunction with Twitter timeline - thanks

 
Posted: 26 September 2010 01:10 AM   [ # 5 ]   [ Rating: 0 ]
Joined: 2008-11-09
1 posts

@adamprocter:

If you want to use it with Twitter Timeline, you need to do two things:

1) Use the created_at variable like this: {created_at format=”%U”}  The %U timestamp format there matches the default output of the {entry_date} variable in the {exp:channel:entries} tag

2) add parse=“inward” to your Twitter Timeline tag:
{exp:twitter_timeline limit=“10” screen_name=“yours” twitter_refresh=“30” parse=“inward”}

parse=“inward” will make sure the timestamp is output before {exp:time_ago} is parsed.

 
Posted: 26 September 2010 11:20 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-26
214 posts

thank you that’s great :D Was using the parse inward anyway for fixing entities too

 
Posted: 18 October 2010 06:17 PM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-22
181 posts

Great news for all (both?) of Youku loving developers - I’ve updated Youku EE plugin!

I’ve added caching - it’s much quicker now!

 
Posted: 21 December 2010 05:51 AM   [ # 8 ]   [ Rating: 0 ]
Joined: 2008-07-03
8 posts

hey, just can’t download the file, please help

 
Posted: 26 November 2011 07:54 PM   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2011-07-13
140 posts

Is this compatible with comment entries?

{exp:time_ago revert_to_date_format="%d %F %Y"}{comment_date}{/exp:time_ago} 

It gives me a syntax error:

Error

The following tag has a syntax error:

{exp:time_ago}

Please correct the syntax in your template.

 
Posted: 12 December 2011 11:38 AM   [ # 10 ]   [ Rating: 0 ]
Joined: 2007-12-19
8 posts

I wish this addon support {edit_date} of entry.

 
Posted: 18 February 2012 11:15 AM   [ # 11 ]   [ Rating: 0 ]
Joined: 2009-10-12
114 posts

I think this is asked above, but does anyone know whether or not you can make this work with the date a comment was posted? Thanks!

 
Posted: 19 February 2012 06:50 AM   [ # 12 ]   [ Rating: 0 ]
Joined: 2009-10-12
114 posts

Well answered my own question by simply trying it and Yes! it does work!

 
Posted: 27 February 2012 12:53 PM   [ # 13 ]   [ Rating: 0 ]
Joined: 2009-10-12
114 posts

All,

Note sure if anyone else is experiencing this, but when testing comments on my site with Time ago installed I keep getting the following error”

A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 7
Filename: time_ago/pi.time_ago.php
Line Number: 68

each time that I submit the comment. If I refresh the comment is there, and its registered ok, just not sure why its throwing this error up?

 
Posted: 20 March 2012 03:34 PM   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-26
214 posts

Updated to latest version of this and latest twitter timeline but parse inwards

{exp:twitter_timeline screen_name=“adamprocter” create_links=“user_mentions|hashtags|urls” parse=“inward”}

means that even with create_links=“user_mentions|hashtags|urls”

Only user_mentions are turned into links ?

Removing create_links=“user_mentions|hashtags|urls”

and user_mentions are still links

any fixes ? please

 
Posted: 30 August 2012 03:22 AM   [ # 15 ]   [ Rating: 0 ]
Joined: 2012-08-28
1 posts
shorn - 27 February 2012 12:53 PM

All,

Note sure if anyone else is experiencing this, but when testing comments on my site with Time ago installed I keep getting the following error”

A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 7
Filename: time_ago/pi.time_ago.php
Line Number: 68

each time that I submit the comment. If I refresh the comment is there, and its registered ok, just not sure why its throwing this error up?

That offset error is happening because one of the variables ($period_count) goes null after periodic refreshes. You’ll notice that you’ll get a “0 ago” when this happens. To fix it, open up the pi.time_ago.php file and find the following code:

// Find the time period unit name
  
$period_unit = ($period_count 1)?($periods[$i]['unit']."s"):($periods[$i]['unit']);
  
  return(
$period_count." ".$this->EE->lang->line($period_unit)." ".$this->EE->lang->line('ago')); 

This should be lines 67-70 (make sure you don’t delete any opening/closing brackets when doing this). Replace the code with:

if ($period_count >= 1)
   
{  
  
// Find the time period unit name
  
$period_unit = ($period_count 1)?($periods[$i]['unit']."s"):($periods[$i]['unit']);
  return(
$period_count." ".$this->EE->lang->line($period_unit)." ".$this->EE->lang->line('ago'));
   
}
   
else
   
{
  
return('Just a moment ago.');
   

That should do the trick. Here’s the whole file with the bandaid fix. Someone may find a more elegant solution, but this is working for me pretty well. Good luck!

<?php

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$plugin_info = array(
      
'pi_name'        => 'Time Ago',
      
'pi_version'     => '0.3',
      
'pi_author'      => 'Milan Topalov',
      
'pi_description' => 'Takes timestamp and returns time passed since as 1 minute ago, 2 hours ago, etc',
      
'pi_usage'       => Time_ago::usage()
     );

class 
Time_ago
{
 
var $return_data "";

 function 
Time_ago()
 
{
  $this
->EE =& get_instance();
  
  
// Load custom language file
  
$this->EE->lang->loadfile('time_ago');
  
  
// Get timestamps
  
$timestamp $this->EE->TMPL->tagdata;
  
$timestamp_now time();
  
  
// Get revert to date format
  
$revert_to_date_format $this->EE->TMPL->fetch_param('revert_to_date_format');
    
  
// If revert to date format set, revert to date if period more then 7 days
  
if ($revert_to_date_format && (($timestamp_now $timestamp) > (60 60 24 7)))
  
{
   $this
->return_data $this->EE->localize->decode_date($revert_to_date_format$timestamp);
  
}
  
// Otherwise return time ago format
  
else
  
{
   $this
->return_data $this->time_ago_in_words($timestamp$timestamp_now);
  
}
 }
 
 
private function time_ago_in_words($timestamp$timestamp_now)
 
{
  
// Time period definitions (length is in seconds)
  
$periods[] = array('unit' => 'year',  'length' => (60 60 24 365));
  
$periods[] = array('unit' => 'month',  'length' => (60 60 24 30));
  
$periods[] = array('unit' => 'week',  'length' => (60 60 24 7));
  
$periods[] = array('unit' => 'day',  'length' => (60 60 24));
  
$periods[] = array('unit' => 'hour''length' => (60 60));
  
$periods[] = array('unit' => 'minute''length' => (60));
  
$periods[] = array('unit' => 'second''length' => (1));

  
$time_difference $timestamp_now $timestamp;

  
// Find the relevant time period unit (e.g. an hour) & calcualte the period count (e.g. number of hours)
  
for($i 0$i count($periods);  $i++)
  
{
   $period_count 
$time_difference $periods[$i]['length'];
   if (
$period_count >= 1)
   
{
    $period_count 
round($period_count);
    break;
   
}
  }

   
if ($period_count >= 1)
   
{  
  
// Find the time period unit name
  
$period_unit = ($period_count 1)?($periods[$i]['unit']."s"):($periods[$i]['unit']);
  return(
$period_count." ".$this->EE->lang->line($period_unit)." ".$this->EE->lang->line('ago'));
   
}
   
else
   
{
  
return('Just a moment ago.');
   
}
 }

 
function usage()
 
{
  ob_start
();
?>  
{exp
:channel:entries}
{exp
:time_ago revert_to_date_format="%d %F %Y"}{entry_date}{/exp:time_ago}
{
/exp:channel:entries}
<?php
  $buffer 
ob_get_contents();
  
ob_end_clean(); 
  return 
$buffer;
 
}
 
}

?> 
 
1 of 2
1