|
jforum example source code file (TemplatesAndStyles.txt)
The jforum TemplatesAndStyles.txt source code
!!! 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|http://freemarker.sf.net] 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|http://freemarker.sourceforge.net/docs/index.html] 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:
[{Java2HtmlPlugin
<#assign name = "My name"/>
<#assign lastName = "Last name"/>
<#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.
[{Java2HtmlPlugin
<#if someConditional>
code code
<#elseif anotherConditional>
code code code
<#else>
more code
</#if>
}]
! Loops
You use the ''<#list>'' directive to iterate over any kind of collection - Lists or arrays.
[{Java2HtmlPlugin
<#list collectionName as variableName>
${variableName.someProperty}
</#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.
[{Java2HtmlPlugin
${aObject.aProperty}
${aObject.someMethod()}
${aObject.anotherMethod("arg1", 2, "arg3", someFreemarkerVariable)}
<#assign result = someObject.myMethod()/>
}]
Other jforum examples (source code examples)Here is a short list of links related to this jforum TemplatesAndStyles.txt source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.