AnsweredAssumed Answered

Custom dashlet: list documents contained in a Space

Question asked by theorbix on Mar 27, 2008
Latest reply on Jul 19, 2010 by rafaelscg
Hello, I would like to develop a "parametric dashlet" that will display the list of documents contained in any valid Space, passing the Space unique name (or unique ID) as a parameter of the Dashlet.

Is such a thing possible?

So far I've developed a prototype Dashlet that uses a very simple freemarker script:

<#ftl strip_whitespace=true />
<#setting locale="it_IT"/>
<#setting datetime_format="short">

<!– Search a given space by its unique node ID –>
<!– This is a workaround since the childByNamePath method does not seem to work… –>
<#assign folderID = companyhome.childrenByLuceneSearch["ID:workspace\\:\\/\\/SpacesStore\\/2f93b4a6-f609-11dc-a589-999071556af1"] />
<#list folderID as child>
   <#assign folderContent = child.children />

<!– Display all documents in the space –>

<script>var AlfNodeInfoMgr = new Alfresco.PanelManager("NodeInfoBean.sendNodeInfo", "noderef");</script>
<table class="recordSet" width=100%>
         <th style="padding:2px;text-align:left" class="recordSetHeader" colspan=2><b>Documento</b></th>
         <th style="padding:2px;text-align:left" class="recordSetHeader"><b>Data aggiorn.</b></th>
      <#list folderContent as child>
         <#assign rowstyle="recordSetRow" />
         <#if (child_index % 2 = 1)>
            <#assign rowstyle="recordSetRowAlt" />
            <#assign rowstyle="recordSetRow" />
         <#if child.isDocument>
           <tr valign=top class="${rowstyle}">
             <td style="padding:2px;text-align:right;vertical-align:top;padding-right:10px;">
             <a href="/alfresco${child.url}" target="_blank">
             <img src="/alfresco${child.icon32}" border=0></a>
             <td style="padding:2px;text-align:left;vertical-align:top;padding-right:10px;">
              <a href="/alfresco${child.url}" target="_blank">${}</a>
               <span onclick="AlfNodeInfoMgr.toggle('${child.nodeRef}',this);">
               <img id="browse:col1-img" src="/alfresco/images/icons/popup.gif" height="16" width="16" class="popupImage" />
             <td style="padding:2px;text-align:left"><nobr>${["cm:modified"]?datetime}</nobr>

The code works well, but unfortunately the ID of the space to be "listed" in the Dashlet output is hardcoded at the beginning of the Freemarker script.

Unfortunately this code is not reusable. With the current approach, if I want to create a "My Alfresco" dashboard with (for instance) three Dashlets showing the content of three different spaces ("Whitepapers", "Brochures", "PowerPoint presentations"), I should define three different dashlets, each pointing to a different .jsp page and a different .ftl script, embedding the space ID.

Ideally, I would have a single Dashlet (maybe based on a WebScript instead than on a Freemarker script as in the current prototype) capable of receiving, as a parameter, the name or the ID of the space to be listed.

Has anyone already done something similar? I would not be surprised, because having a generic "List space content" Dashlet would  certainly be a nice add-on the the Web Client….