On This Day EE Plugin
Okay, my first EE plugin, so be nice.
It's tiny and dead simple: it creates a link to Wikipedia article for whatever day you want; I'm thinking that this will mainly be used with {exp:weblog:entries} {entry_date} field.
Anyone find it interesting?
<?php
$plugin_info = array(
'pi_name' => 'On This Day',
'pi_version' => '1.0',
'pi_author' => 'Sadhana Ganapathiraju',
'pi_author_url' => 'http://www.nikhedonia.com/',
'pi_description' => 'Creates a link to Wikipedia article on the day the post was published',
'pi_usage' => Onthisday::usage()
);
class Onthisday
{
var $return_data = '';
function Onthisday()
{
global $TMPL;
$date = $TMPL->tagdata;
$date = strtotime($date);
if (false === $date || -1 === $date)
{
// Bad date
return;
}
$month = date('F', $date);
$day = date('j', $date);
$link = '<a href="http://en.wikipedia.org/wiki/{0}">Wikipedia on {1}</a>';
$link = str_replace('{0}', $month . '_' . $day, $link);
$link = str_replace('{1}', $month . ' ' . $day, $link);
$this->return_data = $link;
}
function usage()
{
ob_start();
?>
To show a link to the Wikipedia article for a given English date, surround it by the tag:
{exp:onthisday}{entry_date format="%M %d, %Y"}{/exp:onthisday}
Credits: Based on the Wordpress plugin (This Date in History) by Mike Schepker.
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
}
?>
1.
Sue Crocker on December 15, 2006 at 07:58 am
The different example for using this template is to use:
{exp:onthisday}{current_time format="%M %d, %Y"}{/exp:onthisday}This way you have an On this Day for the current day.