Plugin: Number To Date
Posted: 25 August 2008 10:28 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

Hi,

I would like to present to your attention a new plugin - Number To Date.

  The purpose of this plugin is to assist in ordering of entries which have titles
  containing numbers. Order of such entries should match numerical values of numbers
  in titles, as here: “§ 1”, “§ 2”, “§ 3”, ... “§ 10”, “§ 11”, “§ 12”, etc.
  Or as here: ..., “Article 528”, “Articles 529-530”, “Article 531”,
  “Articles 531-533”, “Articles 533-535” etc.

  It is not possible to achieve such order using ExpressionEngine’s ordering of entries by title.
Using ordering of entries by title you will get this order instead:
§1, §11, §12, §13, ... §2, §21, etc.
 
  If real posting date does not matter, needed ordering of entries can be
  achieved by setting posting dates.
  Number To Date plugin automatizes process of calculating dates for such entries.
  It takes as an input a string (which can be title, or url_title,
  or some other string) containing one or two numbers (the second must be
  bigger than the first at least by 1) in the range between 1 and 9999,
  and outputs a date formatted for use in ExpressionEngine’s PUBLISH page.
 
  PARAMETERS:

  1) string - Required. Allows you to specify string containing one or two integers.
 
  2) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when “string”
parameter’s value is invalid plugin exits and PHP alert is being shown;
if the value is “silence”, then in cases when “string” parameter’s value
is invalid no alert is being shown. Set this parameter to “alert” for development,
and to “silence” - for deployment.
  VARIABLE:
 
  1) {computed_date} - outputs id number of parent category.
 
  EXAMPLES OF USAGE:
 

{exp:number_to_date string="article_14" invalid_input="alert"}
  {computed_date}
  {
/exp:number_to_date}


  This code will output: 1990-01-02 04:00 AM
 

{exp:number_to_date string="articles_15_17" invalid_input="alert"}
  {computed_date}
  {
/exp:number_to_date}


  This code will output: 1990-01-02 05:02 AM
 
  ILLEGAL INPUT:
 
  1) “string” parameter’s value contains more than two numbers.
 
  2) Second number included in “string” parameter’s value is equal to or lesser
  than the first number.
 
  3) “string” parameter’s value does not contain any number.
 
  4) Number contained in “string” parameter’s value is zero.
 
  5) Number contained in “string” parameter’s value has leading zero.

I use this plugin in situations when titles of yet to be published entries
are standard, are known in advance and contain numbers. Using this plugin
I am able publish a list of titles together with dates to be set. It is
convenient for content authors since they need not calculate the date
by themselves; instead they can simply copy-paste the date calculated by plugin.
Then ExpressionEngine orders entries by their fictitious dates.

For the situations when titles are standard, contain numbers, but cannot
be known in advance, I have a javascript version of the same script
here.

Continued in the next post

File Attachments
pi.number_to_date_v_1.0.zip  (File Size: 4KB - Downloads: 47)
 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 25 August 2008 10:29 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  290
Joined  02-02-2007

In order to understand how plugin works three cases should be taken into consideration.

  Case A. String, which is the value of “string” parameter contains one integer.
  The plugin will produce a date which is
  later than any date it outputs for any string containing one lesser number and
  earlier than any date it outputs for any any string containing one bigger number.
  E.g if string contains integer “108” the plugin will output a date which is
  later than the date it outputs for string containing integer “107” and earlier
  than the date it outputs for string containing integer “109”.

  Case B. String contains two integers, and the second is bigger than the first
  at least by 1 but no more than 59. E.g. string contains integers “210” and “240”.
  The plugin will produce a date which is (a) later than the date it outputs
  for string containing one integer “210”, (b) later than any date it outputs
  for string containing two integers, one of which is “210” and the second
  is in the range between 211 and 239, and (c) earlier than any date it outputs
  for string containing two integers, one of which is “210” and the second is
  in the range between 241 and 269, and (d) earlier than the date it outputs
  for string containing one integer “211”.

  Case C. String contains two integers, and the second is bigger than the first
  by more than 59. E.g. string contains integers “321” and “398”. The plugin
  will produce a date which is the same as the date it will produce for a
  string containing the integer “321” and an integer bigger than this by 59,
  that is, the same date as for string containing integers “321” and “380”.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
   
 
 
‹‹ Help with Reeposition      MSM path plugin ››
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: 65085 Total Logged-in Users: 39
Total Topics: 82223 Total Anonymous Users: 20
Total Replies: 441915 Total Guests: 221
Total Posts: 524138    
Members ( View Memberlist )
Newest Members:  BombermanhaimtuagocsadamVeNeaDoRHildegaardhrtrulzUNFORGIVEN IIIEmmanuelYanYanTomsB