- Category: 1.0
- Published on Tuesday, 27 April 2010 00:00
- Written by Craig Phillips
- Hits: 5831
EasyTable Pro supports all the standard types found in EasyTable for J! and two additional fields types to help provide better display and sorting features.
It also support field options that affect the formatting of each field, the options vary by type but all support token replacement with values from the current field or other fields.
EasyTable Pro now supports tokens for field rendering. Tokens are replaced with their respective values prior to formatting being applied to a field.
Tokens are indicated by the field alias enclosed in two # symbols. An example table is show below:
TEXT is not a new field type but in EasyTable Pro it now supports the use of tokens to determine how it's rendered.
Taking some fields from the table above, you can specify a field option to display the President's name and a link to Wikipedia in the same cell, by using this field option:
#president#<BR />(<a href="#Wikipedia-Entry#">Wikipedia</a>)
When rendered the #president# and #wikipedia-entry# will be replaced by their prospective values for the current record, to generate HTML something like this:
Barack Obama <BR />
Which in turn will look like this in a browser:
When a field type is set to DATE, EasyTable Pro will render the contents of the field as a PHP date if the raw value in the CSV file was in the standard US English format mm/dd/YY(yy). The US En format for dates is the standard format used by products like Excel, Filemaker, Access, Numbers etc.
If the date value is not a format that can be processed the raw date field will be passed through and a HTML comment will be appended to the raw data. If you don't see the expected date result you can check for the error comment by right clicking and doing a "View Source" or if you're using a developer tool in your browser "Inspect Element".
If the type is specified as DATE and the field options is left blank the date will default to standard PHP default (""F j, Y""), typically of the form January 20, 1993.
DATE + Field Options
If a format string is supplied EasyTable Pro will attempt to render it using the PHP date() function. For the US Presidents table on our Joomla Reference website you will see the format has been left to the default for the date US Presidents "Took office" while the field option for the "Left office" has been specified as "l" (that's a lowercase L) which equates to the full text name of the day of the week.
When the field type is set to NUMBER, then EasyTable Pro will use PHP's number_format() function to render the number.
If no options are provided PHP's default format will apply, so a value of:
will be rendered as
Note the .89 has been truncated and comma's "," have been used to separate the periods of the number.
NUMBER + Field Options
NUMBER's support up to 5 parameters with each parameter separated by a slash "/'. The first 3 correspond to the standard parameters of PHP's number_format(), the addition two parameters add a Prefix and a Suffix.
In order they are:
- Number of decimal places
- Decimal Separator
- Period/Thousands Separator
Taking the number value above and adding these field options: 2/. / , /AUD $/ (Approx.) will render the number as:
AUD $1,234,567.89 (Approx.)
URL's are discussed in this article, but have been extended for EasyTable Pro in the following ways:
- if the URL field starts with a HTML HREF tag "<a href=" then the value of the field is passed through as is.
- if the URL field has no field options then the URL is wrapped in itself to create a clickable link
- Field value= http://www.google.com
- Rendered result = <a href="http://www.google.com" target="_blank">http://www.google.com</a>
- if the URL field has a field option then the is wrapped around the field option to create a clickable link
- Field option= Open Website
- Rendered result = <a href="http://www.google.com" target="_blank">Open Website</a>
- if the field option has a token in it then that will be processed first.
- Field option= Open #name#'s Website (where name is the alias of a field).
- Name field value= Google
- Rendered result = <a href="http://www.google.com" target="_blank">Open Google's Website</a>
If you want to do more advanced manipulation you may want to consider using a field type of TEXT and crafting the HTML directly using the field options (as show in the example above).
Image fields are discussed in this article, but they have also been extended with EasyTable Pro.
Anything found in the field options for an IMAGE field will be used in the <img src as additional tags. ie. it will be inserted into the image tag.
- If the IMAGE has no field options
- and the path to the default directory for images is "/path/to/images"
- it will be rendered <img src="http://d1m23zsnrq5xgh.cloudfront.net/path/to/images/Obama_thmb.jpg" />
- If a field option of alt="President's Portrait Thumbnail" is added
- the HTML will change to <img src="http://d1m23zsnrq5xgh.cloudfront.net/path/to/images/Obama_thmb.jpg" alt="President's Portrait Thumbnail" />
- If a field option of alt="#president#'s Portrait Thumbnail" is added
- the HTML will change to <img src="http://d1m23zsnrq5xgh.cloudfront.net/path/to/images/Obama_thmb.jpg" alt="Barak Obama's Portrait Thumbnail" />
Obviously you can use any of the IMG elements attributes in your field options, they will simply be inserted into the tag.