Templates and styles
All JForum templates are stored in the directory
templates, where each sub-directory is a template name, being the default template name callled
default. There you will find all HTML files, as well Javascripts, images and CSS files.
The table below describes the main templates:
| Filename | Description |
| header.htm | Header for all other templates |
| bottom.htm | Footer contents for all other templates |
| forum_list.htm | Used in forums/list.page |
| forum_show.htm | Used in forums/show.page |
| post_show.htm | used in posts/show.page |
| forum_login.htm | Used in forums/login.page |
| uset_new.htm | Used in user/insert.page |
| pm_list.htm | Used in pm/inbox.page |
| post_form.htm | Used in the Post insertion / editing pages |
| search.htm | Used in search/filters.page |
| search_result.htm | The search results page |
| user_profile.htm | Used in user/profile.page |
Note that there are lot more of templates, many of them being referenced by other templates - includes.
The template engine
JForum uses
Freemarker
as template engine. This means that you don't need to use any Java / JSP code to create the layouts for JForum. It is interesting to take a good look at the
freemarker manual
to learn more about it. In the following section you will find a brief overview of the most common used directives, which should be a good start for starters.
A Freemarker directive starts with <#, and all variables are enclosed by ${}. Inside a directive, you don't use ${} - for example, to output a varialbe value, you write ${variableName}, but if you want to use variableName in an <#if> statement, you simply do '<#if variableName == "someValue">'.
Assign a variable
To create / change a variable in Freemarker, use the
<#assign> directive:
1 <#assign name = "My name"/>
2 <#assign lastName = "Last name"/>
3 <#assign fullName = name + lastName/>
|
Conditionals
Conditionals in Freemarker are
<#if>,
<#elseif> and ended by
<#/if>. You always have to end an
<#if> statement with one
</#if> statement.
1 <#if someConditional>
2 code code
3 <#elseif anotherConditional>
4 code code code
5 <#else>
6 more code
7 </#if>
|
Loops
You use the
<#list> directive to iterate over any kind of collection - Lists or arrays.
1 <#list collectionName as variableName>
2 ${variableName.someProperty}
3 </#list>
|
where collectionName is any kind of array of java.util.Collection, and variableName is the local variable you will use inside the block.
Calling properties and methods
To call any property or method, just use the dot notation.
1 ${aObject.aProperty}
2 ${aObject.someMethod()}
3 ${aObject.anotherMethod("arg1", 2, "arg3", someFreemarkerVariable)}
4 <#assign result = someObject.myMethod()/>
|