cancel
Showing results for 
Search instead for 
Did you mean: 

Create a forum view using FreeMarker templates

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

Has somebody already wrote a template to display the hierarchy of topic/posts of a forum or document discussion ?
As you may know a discussion contains all its posts, and the posts have cm:references relationships between then to remember which one is the answer to another one. I want to write a template to really show the answers hierarchy, like :

Discussion1
—Post1
——Answer1
———Answer to Answer1
———Other answer to Answer1
————Answer to Other anwer…
——Answer2
——Answer3
—Post2
——Answer to Post2
Discussion2


and so on…

Is it possible in FreeMarker to display an unlimited hierarchy ?
Should it be done using the "recurse" instruction ?
Any help/idea would be appreciated !
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
You can use Macros and Functions in FreeMarker to recursively display and walk structures.

If anyone has written this template, they are welcome to post it here or to the community page for templates:
http://wiki.alfresco.com/wiki/Example_Presentation_Templates

Thanks!

Kevin

mcolak
Champ in-the-making
Champ in-the-making
<#macro findparent node>

<#if node.properties.name = "Company Home">

<#else>


    ${node.properties.name}
    <@findparent node.parent/>
</#if>

</#macro>


  <@findparent node=space />

/// code finish

you can use recursive

rivarola
Champ on-the-rise
Champ on-the-rise
Thanks for the example mkolac  Smiley Very Happy