Print

What are F2C article templates?

Templates are used to present data in a pre-defined layout. Just like Joomla templates are used to determine the layout of a Joomla website by defining the module positions.

In Form2Content the F2C article templates are used to define the layout (presentation) of the Joomla article content.

Note: Linking to Joomla articles is done in the native Joomla way using Menus and layouts (through com_content).

Default templates

Form2Content creates default templates in order for users to immediately experience the working of F2C. Whenever a content type is created, F2C automatically generates a default template set (intro and main) and links to it.

As a result, when you submit your first article with F2C it will actually generate a Joomla article since there is a template present.

Remember: form content (data) + article template (layout) = Joomla article (html)

DO NOT EDIT THE DEFAULT TEMPLATES UNLESS YOU HAVE SWITCHED OFF THE CREATE DEFAULT TEMPLATE SETTING IN THE CONFIGURATION!

F2C Template location

The Form2Content templates are saved in:

< website root > /media/com_form2content/templates

Print

Using Smarty template engine in F2C

Please read the documentation on PLUGIN use and Smarty here!

What is a template engine?

A very fair question to begin with. We use a template engine to render (paste) the data from the submission forms into our article templates. The template engine allows us to use a simple syntax (tags) in to assign the places where the information will be pasted.

In Form2Content we call these 'tags' Template Parameters. Each F2C template parameters is a reference to a bit of data from the submission form.

An example

If there is a text area (field type) in the F2C submission form called "introduction", users can add plain text into the text area.

Now if we want to show the text in our article we need to add the following Template parameter to our introduction template.

{$INTRODUCTION}

The Smarty template engine also allows us to do many other things like only use the first 200 characters of the text. In this case the template parameter would look like this:

{$INTRODUCTION|truncate:200}

Since Smarty is 'smart' it will leave tha last word in one piece.

Smarty documentation

One of the reasons we have chosen Smarty is because of the active support website and documentation. Please follow the following links to the Smarty website for extensive documentation.

Documentation: http://www.smarty.net/docs.php (different languages)
Forum: http://www.smarty.net/forums/

Print

F2C Template parameters

Template Parameters are used to 'paste' the data (article information) from the F2C submission forms into the F2C Template (your article layout). This than creates the html for your Joomla article.

There are two types of Template Parameters, Joomla based parameters and Form2Content field parameters. The Joomla parameters are all the different values related to normal Joomla articles.

Simple example of Joomla based template parameter

The article title can be used anywhere in your F2C Template, simply add the {$JOOMLA_TITLE} parameter.

<h2>Author of {$JOOMLA_TITLE}</h2>

 

The template parameters can be used in combination with almost any Joomla plugin. The result: place your plugin tags in your F2C template and let your users simply add content.

Joomla based F2C Template Parameters (for Smarty templating)

Value Template Parameter Example for use LITE
Title {$JOOMLA_TITLE} place the tite in the alt text for an image for SEO tick
Title alias {$JOOMLA_TITLE_ALIAS} on request tick
Article ID {$JOOMLA_ID} ID of the article. tick
Section title {$JOOMLA_SECTION_TITLE} Section Title publish_x
Section ID {$JOOMLA_SECTION_ID} Create URLS publish_x
Section title alias {$JOOMLA_SECTION_ALIAS} Section Title Alias publish_x
Category title {$JOOMLA_CATEGORY_TITLE} Section Title publish_x
Category ID {$JOOMLA_CATEGORY_ID} Create URLS publish_x
Category title alias {$JOOMLA_CATEGORY_ALIAS} Section Title Alias publish_x
Start publish date {$JOOMLA_PUBLISH_UP} Start publish date tick
Stop publish date {$JOOMLA_PUBLISH_DOWN} Stoppublish date tick
Article Link {$JOOMLA_ARTICLE_LINK} To create your own read more .... tick
Meta keywords {$JOOMLA_META_KEYWORDS} for plugins which use the keywords as tags publish_x
Meta description {$JOOMLA_META_DESCRIPTION} If you want to show it ... publish_x
Author Full Name {$JOOMLA_AUTHOR} Use the name anywhere publish_x
Author Username {$JOOMLA_AUTHOR_USERNAME} just so you can :) publish_x
Author alias {$JOOMLA_AUTHOR_ALIAS} on request publish_x
Author Email {$JOOMLA_AUTHOR_EMAIL} Use the email anywhere publish_x
Article create date {$JOOMLA_CREATED} on request tick
Article modified date {$JOOMLA_MODIFIED} on request tick

F2C based Template Parameters

Please note. The is a reference to the unique name you give a form field when you create it. It should always be used in CAPITALS in the form2content template.

Replace < FIELDNAME > with the unique name of your F2C field.
Value Template Parameter Explanation for use LITE
F2C article ID {$F2C_ID} By request, renders the F2C id of the article publish_x
Fieldname (any type) {$< FIELDNAME >} Displays the value of the field tick
Fieldname caption {$< FIELDNAME >_CAPTION} Displays the caption value of the field tick
Fieldname title {$< FIELDNAME >_TITLE} Displays the title value of the field tick
Select List value {$< FIELDNAME >} Displays the selected value from a list (NO UTF-8) tick
Select List Display text {$< FIELDNAME >_TEXT} Displays the text of a selected value (With UTF-8) tick
Image URL absolute {$< FIELDNAME >} includes the domain name in the url of the image tick
Image URL relative {$< FIELDNAME >_PATH_RELATIVE} the path to the image relative to images/stories/ publish_x
Image thumb URL absolute {$< FIELDNAME >_THUMB_URL_ABSOLUTE} includes the domain name in the url of the thumb tick
Image thumb URL relative {$< FIELDNAME >_THUMB_URL_RELATIVE} the path to the thumb relative to images/stories/ tick
Thumbs directory absolute {$F2C_IMAGES_PATH_THUMBS_ABSOLUTE} Absolute path to the thumbs directory of the F2C article publish_x
Thumbs directory relative {$F2C_IMAGES_PATH_THUMBS_RELATIVE} Relative path (in images/stories/) to the thumbs directory publish_x
Image directory absolute {$F2C_IMAGES_PATH_ABSOLUTE} Absolute path to the image directory of the F2C Article tick
Image directory relative {$F2C_IMAGES_PATH_RELATIVE} Relative path (in images/stories/) to the image directory tick
File Upload {$< FIELDNAME >} Raw url of hyperlink to file publish_x
File name {$< FIELDNAME >_FILENAME} The name of the file publish_x
Relative file URL {$< FIELDNAME >_URL_RELATIVE} Relative path (in media/com_form2content/documents/...) to the file publish_x
Database Lookup {$< FIELDNAME >} Value of the choice made publish_x
Database Lookup Text {$< FIELDNAME >_TEXT} Text of the choice made publish_x
Custom list output {$< FIELDNAME >_CUSTOM_FORMAT} Used to create comma seperated (other) output instead of LI or UL publish_x
Geo coder field {$< FIELDNAME >_ADDRESS} = The address line.
{$< FIELDNAME >_LON} = The longitude code
{$< FIELDNAME >_LAT} = The latitude code
Translates address to longitude/latitude publish_x
Print

Two F2C templates and 'read more', how does it work?

The 'read more' function in Joomla has a long, somewhat important history which has effect to this day. In Joomla 1.5 there is only one editor when you open an article. Underwater (i.e. in the database) there are however 2 fields where data is saved, one for the intro and one for the main content of the article.

When we are using F2C to create a Joomla article we need to 'fill' both database fields. To do this we require two separate F2C templates. The f2C intro template and the f2c main template.

Print

Using Joomla Plugins with F2C (Smarty) templates

Anyone with some Joomla experience will have noticed that the curly brackets {} used by Smarty are also used by many (3rd party) Joomla Plugins. And YES, this does create a CONFLICT.

BUT THERE IS AN EASY SOLUTION ( actually two solutions)

Using alternatives for { and } symbols

Instead of using the curly brackets use the following

{ becomes =  {ldelim}
} becomes = {rdelim}

Example: Google Map plugin by Mike Reumer and F2C Geo Coder field type named ADDRESS.

{ldelim}mosmap lat='{$ADDRESS_LAT}'|lon='{$ADDRESS_LON}'|text='{$ADDRESS_ADDRESS}'
|tooltip='{$JOOMLA_TITLE}'|marker='1'|align='center'{rdelim}

Wil generate the following in your Joomla article if "Ceresstraat 24, 4811 Breda, The Netherland" is filled out as address in the F2C submission form.

 {mosmap  lat='37.0625'|lon='-95.677068'|text='Ceresstraat 24, 4811 Breda, The Netherlands'
|tooltip='My test article'|marker='1'|align='center'}
 

Always make sure that if you copy/paste code you remove any
tags or spaces for the code to work properly!

More info: http://www.smarty.net/manual/en/language.function.ldelim.php

Block escaping code in Smarty

It is also possible to escape blocks of code. In other words, not replace individual {} symbols but telling Smarty not to do anything with the code between the tags. The term they use is 'literal', i.e. render the literal code.

Take note: If you have variables ( {$VARIABLE_NAME} ) within a block they will NOT be rendered.

{literal} ... any code including {} tags ....  {/literal}

More information: http://www.smarty.net/manual/en/language.function.literal.php

Print

Advanced F2C templating with Smarty

Article templating can be more than just a question of copy/pasting information from the submission form into the Joomla article. Using the Smarty template engine and some nice F2C template parameters there is a lot more possible.

Form2Content no longer provides documentation for patTemplate use. All examples use Smarty templating! Old patTemplate templates are backwards compatible in Joomla 1.5 but new features have not been added.