This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JForum and the fly likes Custom Forum Headers Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » JForum
Reply Bookmark "Custom Forum Headers" Watch "Custom Forum Headers" New topic
Author

Custom Forum Headers

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I was wondering if there was a way to have a custom Masthead for each forum. I understand that I can include an image in the initial entries of each topic but that doesn't fit my purposes as I'm hacking the default JForum theme within an inch of its life (I'll post the URL when I'm done). I was thinking something more along the lines of:

If forum ="forum name" then display "forum div" or else display nothing.

Is this possible?

Thanks in advance for any help.

Eric


[originally posted on jforum.net by slowhome]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I think Freemarker lets you wrap includes inside if statements. Also on the forum and view topic pages, there is generally a "forum" object in the FreeMarker context. You can probably combine these two in the correct template files to do something like:



Where id is the id number of the forum (database key).
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Didn't work. Here's what I put in forum_show.htm

<#if forum.id == {1} >
<#include "includes/customMasthead.htm" />
<#elseif forum.id == {1} >
<#include "includes/customMasthead.htm" />
<#else>
<#include "includes/defaultMasthead.htm" />
</#if>


This is what the console barfed out:


freemarker.core.ParseException: Encountered "}" at line 57, column 20.
Was expecting one of:
"," ...
":" ...
"." ...
"[" ...
"(" ...
"?" ...
"!" ...
"??" ...
"+" ...
"-" ...
"*" ...
"/" ...
"%" ...
"!=" ...
"=" ...
"==" ...
"=" ...
ESCAPED_GTE ...
"" ...
ESCAPED_GT ...
LESS_THAN_EQUALS ...
LESS_THAN ...
".." ...
AND ...
OR ...


I've verified that the forum.id is correct. The includes work if not wrapped in the statement.

Thanks for any help.

Eric
[originally posted on jforum.net by slowhome]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Sorry, the {} part was just my way to indicate a replacement item. Just put the number there and no curly braces.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Works perfectly! Thanks for your help.
[originally posted on jforum.net by slowhome]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
FWIW, Looking at your sample.. you don't need the second

<#elseif forum.id == {1} >
<#include "includes/customMasthead.htm" />

part unless you are doing more than one custom mastHead. E.g., Forum id 2 has a different one from 1.

I was just trying to indicate that you can string together a bunch of different forum id's and mastheads with the elseif statements if you need to.
[originally posted on jforum.net by monroe]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Custom Forum Headers
 
Similar Threads
questions about overloading
how to show map of maps in jsp,struts
glyphs
problems displaying values in JTable
Need help creating custom ComboBoxEditor