Custom Article Templates

Using Article Templates to create consistent layout for your articles is very powerful. Think of batch updating and logic in your content as a few examples.

A few points to take into account

  • The default templates are only there to make F2C work immediately.
  • Start using your custom templates immedialtely!!
  • Article Templates can be very very simple, as we will show.
  • In Joomla you can set article intro to is or is not shown at the top of your article page.
  • We use the Smarty template system because it's easy and powerful.
IMPORTANT: At this point we assume you have created a Content Type and added some custom fields to your submission form. Adding an article through the F2C Article Manager works but you get an article with "This is the default layout ...."

Two 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 (up until 2.x) there was one editor for an article but "underwater" (i.e. in the database) there where 2 database fields, one for the intro and one for the main content of the article....as a result Form2Content required two separate Article Templates. The intro template and the main template.

Read more link
In Joomla the 'read more' link in the category blog layout is automatically shown when an article has a read more tag. Since you are now using Article Templating you don't need to add this anymore, Form2Content will add this.

IMPORTANT: In Form2Content you should NEVER add the Joomla read more tag in your content or templates. Form2Content does it for you the moment there is any content in the main template.

Why does it work this way?
There are two reasons why F2C works this way. First reason is the above one and can be seen as Joomla legacy. The second reason is more important. We want the web developer to determine where the read more tag is added, not the user. 

Step 1: Create your two template files

Create two files (.tpl or .htm(l)) with any name on your computer. The first will be the template for your introduction text (which you see in Joomla in the category blog layout) and the second for the main body (Joomla article). Preferable extension is .tpl.

custom_intro.tpl
custom_main.tpl

NOTE: If you leave the second template empty or don't link to it, it will have the same effect as when you DON'T use a read more tag in your Joomla article.

Step 2: Add your layout, plugins and template parameters

Your custom templates need to show the data from your custom forms. This is done using Template Parameters.

Edit the files with a HTML editor and add your layout. You should now add your custom fields to your template. Remember, use the field names in CAPITALS.

Example:

Let's assume we build our form with two text area fields called intro_text and main_text and an image field called intro_image (set to RAW output!!).

Intro template could be as simple as:

<div class="f2c_intro">
{if $INTRO_IMAGE}
<img src="/{$INTRO_IMAGE}" align="right" alt="{$JOOMLA_TITLE}" />
{/if} 
<p>{$INTRO_TEXT}</p> 
</div>

And the main template:

{if $MAIN_TEXT}
<div class="f2c_main">{$MAIN_TEXT}</div>
{/if}
The Smarty IF statements are added so that if NO image is added it won't show and if NO main text is added there won't be a read more link (since the template file will be completely empty!)

Step 3: Save the template files & upload to your website

Using the template manager to upload your template files.

Alternatively: Use a FTP/HTML editor to upload your template files and save them in the following folder.

/media/com_form2content/templates/

Step 4: Using/linking to your custom templates

Go back to the Content Type configuration and select the newly generated template files to be used as the default templates.

Menu: Components => Form2Content => Content Type Manager , select your content type and edit.

SAVE your changes.

Step 5: Update the templates in existing F2C articles

If you change the default used template files in the content type configuration and there are F2C articles using the old template, make sure to edit those articles in the back-end and select the new templates to be used for rendering.

If you save your NEW template with the same name of your existing template you don't need to update the articles you already made but just refresh them via the F2C Article manager (select all, click refresh).
 

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