Form2Content Templating

The Form2Content Templates are combined with the information from the forms to create the HTML which is inserted into the Joomla database as an article. Each Content Type (project) has field variables which you can create in the Project Manager. These variables can be called and displayed in the template. Using patTemplate codes it is possible to be very creative with your templates and include conditional statements.

Use of Intro & Main Template

Attention: open in a new window. Print

Joomla used to have two parts to every article, the Intro Text and the Main Text. From Joomla! 1.5 onwards these two parts have been combined into one Text Area (with WYSIWYG editor depending on your settings).

Inserting the READ MORE line will split your article into the Intro Text and Main Text. If the Read More is used, the Read More link will automaticaly show in Blog Layout views of your articles. Depending on your article parameter settings the Intro Text will or won't be shown when you view the article as a whole. This is all basic Joomla! and has so far nothing to do with Form2Content.

In the Joomla! database there are still two fields to every article, one for the intro text and one for the main text. If any text (html) is present in the main text field, Joomla! will render the Read More link in Blog Layouts.

Form2Content Templates

For Form2Content to be as simple and flexible as possible we have provided the use of two templates per article. The Intro Template for the Intro Text and the Main Template for the Main Text.

F2C without Main Template

If the Main Template is not used, there will be no Read More link in the Blog Layout since there is no text (html) in the main text field of the article.

F2C with Empty Main Template

It is also possible to include a Main Template but not place any code between the template tags. Again no content will be rendered into the Main Text field of the article so no Read More link will show.

F2C with Conditional Main Template

It is very linkely that at some point you want to create a Content Type where the user has the option to add more information which will be visible after a Read More.

Two or more fields with conditional statement

The easiest is to create (at least) two Text Areas (with or without editor). Name one for instance Intro Text, the other Read More Text.

 

   

F2C Template Parameters

Attention: open in a new window. Print

There are several template parameters which can be used in creating the content of your F2C Articles. Some are based on Joomla information, others on the Fields you have created for the Article submission form.

The template parameters can be used in combination with almost any plugin to get the desired effect for your content without the person submitting the information needing any html/plugin knowledge.

Joomla based F2C Template Parameters

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

Author Email

{JOOMLA_AUTHOR_EMAIL} Use the email anywhere

F2C based Template Parameters

Value Template Parameter Explanation for use
Fieldname {<fieldname>} Displays the value of the field
Select List value {<fieldname>} Displays the selected value from a list (NO UTF-8)
Select List Display text {<fieldname>_TEXT} Displays the text of a selected value (With UTF-8)
Image URL absolute
{<fieldname>} includes the domain name in the url of the image
Image URL relative
{<fieldname>_PATH_RELATIVE} the path to the image relative to imagaes/stories/ (COMING in version 2.2.0)
Image thumb URL absolute
{<fieldname>_THUMB_URL_ABSOLUTE} includes the domain name in the url of the thumb
Image thumb URL relative
{<fieldname>_THUMB_URL_RELATIVE} the path to the thumb relative to imagaes/stories/
Thumbs directory absolute {F2C_IMAGES_PATH_THUMBS_ABSOLUTE} Absolute path to the thumbs directory of the F2C article
Thumbs directory relative {F2C_IMAGES_PATH_THUMBS_RELATIVE} Relative path (in images/stories/) to the thumbs directory
Image directory relative {F2C_IMAGES_PATH_ABSOLUTE} Absolute path to the image directory of the F2C Article
Image directory relative {F2C_IMAGES_PATH_RELATIVE} Relative path (in images/stories/) to the image directory
File Upload {<fieldname>} Raw url of hyperlink to file
File name
{<fieldname>_FILENAME} The name of the file
Relative file URL
{<fieldname>_URL_RELATIVE} Relative path (in media/com_form2content/documents/...) to the file
Database Lookup
{<fieldname>} Value of the choice made
Database Lookup Text
{<fieldname>_TEXT} Text of the choice made

 

   

Creating a Form2Content Template

Attention: open in a new window. Print

The Form2Content templates are very easy to make but have a few little things you should remember and apply.

Please do NOT edit the default Template created by Form2Content for every Content Type. This file is rewritten when new fields are added or edited. Simply upload a new template (.tpl or .html file) using the Template Manager of via FTP into media/com_form2content/templates directory.
If you open your default intro template file you can see all the Template Parameters of your custom fields of that Content Type.

File Format of the template files

The file format can be either .html or .tpl. All html markup and plugin codes can be inserted.

patTemplate Tags of your Template Files

Important: Place your custom code between the following patTemplate tags. These are your first and last line of code ... always!

... your code ....

Don't use any tags like body or head since the templates are just for html, added to the article body like in your normal Joomla! article editor.

Including your Template Parameters

Next add your template parameters. These are the (unique) Field Names of the custom Fields you added to your submission form.

Always add the name of the template parameters in CAPITALS

{COMPANY_LOGO}
{COMPANY_NAME}
{COMPANY_DESCRIPTION}
{JOOMLA_TITLE}

Including your custom layout

And last, include any styling you like within your template. Don't forget the great possibility of including plugins.


{COMPANY_LOGO}
Company name: {COMPANY_NAME}
{COMPANY_DESCRIPTION}

This shows the Article Title used in the Template: {JOOMLA_TITLE}.
   

The Template Manager

Attention: open in a new window. Print

The Template Manager shows the templates which are found in the media/com_form2Content/templates folder. Whenever a new Content Type (project) is created and the first Form Fields are added, a new default template for that project is created. In the Default Template the template code for the created Form Variables (Fields) will be shown.

It is possible to upload your own template in which you have placed the unique field values of your Content Type within your layout. Below an example used as the intro template on the DEMO website.


{COMPANY_LOGO}
Company name: {COMPANY_NAME}
{COMPANY_DESCRIPTION}

This shows the Article Title used in the Template: {JOOMLA_TITLE}.
   

patTemplating

Attention: open in a new window. Print

Form2Content Templates can use patTemplating syntax to create dynamic effects in the template. Conditional statements will be used most to show or hide layout depending on the value of a field. Using conditional statements will enable you to easily integrate plugins and css styling without having layout problems when someone hasn't filled out all the fields within a F2C Article.

Simple Conditional statement

If field has content show everything between the tags.


Field caption is not a variable yet:
{FIELDNAME}

Conditional statement for a Select Box

If condition is true, show Yes, if false (default), show No.


Yes
No

patTemplate Truncate function with conditional statement

There is a truncate function in patTemplate which allows you to cut the text of a variable (in our case a F2C Field) at a set length.




NOTE: There is one problem with this approach. If you use html tags in your content (i.e. use of an editor) these will also besplit so it is best to use a Text Area field without editor for your input.

Link: patTemplate Documentation
   

Including plugins/mambots in your F2C Template

Attention: open in a new window. Print

Including the codes for plugins (mambots) is as simple as placing them in your usual articles. If you want to include a code only in one artcile sinple place it ina field in your form while filling it out.

If you like to include a plugin in ALL your Articles of a Content Type created by Form2Content you include the code in the F2C Template.

Example of including a Xtypo quote if entered in the Article form:

  
{xtypo_info}{QUOTE}{/xtypo_info}
 

And with some layout:


Our quote is: {xtypo_info}{QUOTE}{/xtypo_info}
   

Royalty Free Images
Verschillende betaalmethoden

Open Source Design

Ceresstraat 24
4811CC Breda
The Netherlands
+31(0)765152174