• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Notes on theming

Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mostly, I havn't mentioned theming, because JForum is an excellent piece of work.

A lot can be done with CSS, especially now the content pseudo-elements 'before:' and 'after:' are standard. If you can rely on newish browsers, using a JForum binary and CSS will save time and look good. The page structural changes seem on JavaRanch will not be possible, though.

To change page structure, the Freemarker templating will need altering (even for commenting out - see below). Aside from Java inconsistency, FreeMarker is very nice. Look at the Freemarker site, and it's exceptional (a real standout in the Java arena) documentation,


and start work.

Below are notes on more substancial theming.

Try convert a PHPBB2 template
JForum is, as API and database structure, based on PHPBB2. The default theme is, I read, a conversion of the 'silver' theme. So a conversion of a PHPBB2 theme, of which there are many, may be possible.I've not tried this, and assume there will be grunt work involved in converting to FreeMarker markup.

Don't be mislead by the two source scripts,


These are for importing PHPBB2 databases into JForum, not converting templates.

Earlier post on this,

Some notes on more substantial Freemarker hacking
I would have liked to know these...

Freemarker templates should usually be commented out using Freemarker comments
Sounds obvious, but surrounding a snippet with HTML escapes,

will have little effect. This will remain operative Freemarker code, and the result will show in final output - only the end-user browser will ignore it (which may have uses in some debugging operations, but not many).

Whereas commenting using Freemarker comment code,

is not acted upon as operative code, and is never sent from the server as HTML.

Freemarker 'includes' addressing
...is either relative to the template, or absolute to whatever is declared as the template folder in the setup of Freemarker in the servlet. In JForum, that means an absolute address like,

<#import "/macros/imageMacros.fm" as imageUtils/>

looks for imageMacros.fm in,


not mySite/WebContent/WEB-INF/.

Freemarker 'includes' are alive to variables in scope
If "subtemplate.htm" is included into "post_show.htm",

..."subtemplate.htm" can include code referring to "post_show.htm" variables like this ,

Macros don't work directly, they need namespacing and assigning
As someone who has used macro languages, this had me beating through documentation. The below example should illustrate all,

For more direct work, use '<#includes ...>'.

If you remove active code from forms, cascading issues with support code can be patched using hidden elements
Maybe this is not a great idea in the long run. However, I, for example did not need ratings ('karma', in JForum). Other sites may wish to deprecate features such as private messages, HTML messages, etc. Sometimes there is no big switch to turn everything off (though changes can often be can be done using group permissions, and even an SQL script. Since I like to retain a degree of forward compatibility, that's my preferred route).

Anyhow, trying to deprecate a feature can be difficult in the first instance - it keeps appearing again and distracting from overall theming. And, in the end, the template code is unnecessary, particularly in forms.

Simply removing the templating and code is not trivial, as the code which receives the form will expect the data on, say, 'karma' to be there. This can be solved, at least temporarily, by supplying the code in a hidden element.

For example, let's say a user can never make a choice on using HTML, they must always use plain text. In 'user_form.htm' comment out the option,

Now, somewhere close to the comment, add an extra line to supply the missing data, set to '0', to say HTML is never allowed,

Now the user never sees the option, but all code summoned on the server side should work correctly.
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic