Plugin: Formatted Date
Posted: 07 October 2008 05:39 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  284
Joined  02-02-2007

Hi,

I have rewritten Lodewijk Schutte’s Nice Date plugin. The result is Formatted Date plugin.

The difference from original plugin is possibility to set global values for “format” and “localize” parameters which allows to use these parameters only in cases when global values need to be overridden.

PARAMETERS

1) format - Optional. Allows you to specify how date should be formatted.
About date formatting see here.

In case no global format is set format parameter must be specified.

2) localize - Optional. Allows you to specify if the date should be localized.
Possible values are “yes” and “no”. Default is “no”.

SETTING GLOBAL VALUES

You can set global values for “format” and “localize” parameters

1) by setting values to $default_format and $default_localize variables on top this plugin’s
code as here:

// Here you can define default format for dates
$default_format = '%F %j%S, %Y';
$default_localize = 'yes';

or

2) by defining global_date_format and global_date_localize global variables inside path.php file.
To do this enter the lines as these inside path.php:

$global_vars = array(
"global_date_format" => "%F %j%S, %Y",
"global_date_localize" => 'yes'
);

Setting global_date_format and global_date_localize global variables inside path.php file has one advantage over setting values for $default_format and $default_localize variables on top this plugin’s code - you can use these variables not only with Formatted Date plugin but also together with other tags and variables. For example, if you have global_date_format variable specified in path.php then you can write such code:

{current_time format="{global_date_format}"}

Preference order of “format” and “localize” parameters, $default_format and $default_localize variables
and default_date_format and default_date_localize global variables is as follows:

1) plugin reads value of “format” or “localize” paramer and uses it in case it is specified;

2) if there is no such parameter, then the plugin uses the value of “default_format” or
“default_localize” variable if it is not equal to empty string;

3) if the value of “default_format” or “default_localize” variable is equal to empty string,
then the plugin finds if there is global variable “global_date_format” or “global_date_localize”
specified in path.php file and uses its value.

USAGE

In case no global value for format and localize are specified or global values for format and localize
need to be overridden:

{exp:fdate date="2008-10-07" format="%F %j%S, %Y" localize="yes"}

In case global values for format and localize are specified:

{exp:fdate date="2008-10-07"}

Using the tag together with URL segment variables:

{exp:fdate date="{segment_3}-{segment_4}-01"}

Changelog:

-1.0 // Initial release

File Attachments
pi.fdate_v1.0.zip  (File Size: 2KB - Downloads: 30)
 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

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: 64912 Total Logged-in Users: 24
Total Topics: 81864 Total Anonymous Users: 26
Total Replies: 440107 Total Guests: 200
Total Posts: 521971    
Members ( View Memberlist )
Newest Members:  bjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkeybenekwhobutsb