F2C Smarty code (snippets)

Displaying date fields as textual dates in Smarty templates

When you use date fields in your template they are output in a numeric way like this: 27-06-2012.
Often you might want to display them textually e.g. Wednesday, June 27, 2012.
This tutorial will show you how to do this.

Displaying the date textually can be accomplished by using the Smarty Variable Modifier date_format. The official Smarty documentation can be found here.

In an F2C template you should use the raw date format in combination with this function like this:

{$JOOMLA_CREATED_RAW|date_format:"%A %e %B %Y"}

This example will output this date: Wednesday, June 27, 2012

Please note that the textual output will be generated based on the locale your server is running on. If you want the date in a different language, you have to set the locale manually in the template by using a piece of PHP code. The code you must use is different for a Windows or a Linux environment.

For instance, to set the locale to Dutch, this is the syntax for Linux:

{php}setlocale(LC_ALL, 'nl_NL');{/php}

Or in case of an error just the time stamp:

{php}setlocale(LC_TIME, 'nl_NL');{/php}

And this is the syntax for Windows:

{php}setlocale(LC_ALL, 'nld_nld');{/php}


Full documentation on the setlocale syntax can be found here.

Running the above example again with the new locale setting will result in this output: woensdag, juni 27, 2012

F2C Cheat-sheet

An overview of all template parameters (placeholders for your form data). These are used in your F2C intro and main template to parse the data from your submission forms into the Joomla article.

Download

Footer

Form2Content, a Joomla CCK Documentation © 2010 - 2015 Open Source Design | Powered by Form2Content