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
