aspose file tools*
The moose likes JForum and the fly likes Notes on theming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "Notes on theming" Watch "Notes on theming" New topic
Author

Notes on theming

robert crowther
Ranch Hand

Joined: Oct 19, 2013
Posts: 41
    
  10
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,

http://www.freemarker.org/

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,

phpbb2JForum.bat
phpbb2JForum.sh


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

Earlier post on this,
http://www.coderanch.com/t/574462/jforum/building-templates#2614633


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,

mySite/WebContent/templates/myTemplate/macros/

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Notes on theming