Many improvements were made, and bugs were fixed.
  • Is JForum useful for you? Please consider helping this project.
 
 
 
 
 

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:

FilenameDescription
header.htmHeader for all other templates
bottom.htmFooter contents for all other templates
forum_list.htmUsed in forums/list.page
forum_show.htmUsed in forums/show.page
post_show.htmused in posts/show.page
forum_login.htmUsed in forums/login.page
uset_new.htmUsed in user/insert.page
pm_list.htmUsed in pm/inbox.page
post_form.htmUsed in the Post insertion / editing pages
search.htmUsed in search/filters.page
search_result.htmThe search results page
user_profile.htmUsed 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()/>