cancel
Showing results for 
Search instead for 
Did you mean: 

Access the forums on a folder (fdl)

dbrunner
Champ in-the-making
Champ in-the-making
For accessing the forums on a document via fdl, one may use the following command (assuming that doc is a reference to the document) :

<#list doc.children[0].children as forum>
  …
</#list>

How can I access the forums on a folder ?

Daniel
5 REPLIES 5

gavinc
Champ in-the-making
Champ in-the-making
Both documents and folders both use the fm:discussion child association.

Folders already have a child association called 'cm:contains' for the sub folders and files. So for a folder you'll need to pick out the fm:discussion child association specifically.

It just so happens that documents usually don't have any child associations so referencing doc.children[0] would normally give you the fm:discussion child association (if its present). However, this is not guaranteed, documents could have other child associations too so your code should really be specific about the child association you mean in both scenarios.

Hopefully Kev can respond with the freemarker syntax you'll need to do that!

kevinr
Star Contributor
Star Contributor
Accessing named child associations (as you need to do this) is available as part of the Alfresco FreeMarker API in 2.1, in the latest code available now, such as a nightly build: http://dev.alfresco.com/downloads/nightly/dist

Once you have the latest code (or wait for the 2.1 release) the syntax is: doc.childAssocs["fm:discussion"][0]

Hope this helps,

Kevin

dbrunner
Champ in-the-making
Champ in-the-making
We are actually using the V1.4 in production so I would need the example for V1.4 of Alfresco…

Thans in advance.
Daniel

kevinr
Star Contributor
Star Contributor
Using the 1.4 API you could identify which of the child nodes is the one you want by comparing the type of each one until you find one of type: {http://www.alfresco.org/model/forum/1.0}:forum

Thanks,

Kevin

dbrunner
Champ in-the-making
Champ in-the-making
Great, it'is working. Here a small sample :

<#if space.isContainer>
   hello, I am a container<p>
    <#list space.children as forums>
       <#if forums.type = "{http://www.alfresco.org/model/forum/1.0}forum">
           <b>${forums.properties.name}</b><p>
           <#if forums.isContainer>
              <#list forums.children as topic>
                <#if topic.type = "{http://www.alfresco.org/model/forum/1.0}topic"><p>
                   <b>${topic.properties.name}</b>
                 </#if>
              </#list>
           </#if>
       </#if>
    </#list>
</#if>