cancel
Showing results for 
Search instead for 
Did you mean: 

Listing document categories as part of webscript search rslt

shikarishambu
Champ in-the-making
Champ in-the-making
I have custom web script that searches my Alfresco repository and lists the documents. I would like to be able to show the list of categories associated with the document as part of the search result.

I have tried referencing it in my search.get.xml.ftl as
<categories>${row.properties["cm:categories"]}
. However, I am getting an error. I would like to find out if there is a way to get the list of categories. Ideally, I would like to get a comma separated list of categories.

TIA
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
Try something like this:
<categories><#list row.properties.categories![] as c>"${c.name?xml}"<#if c_has_next>,</#if></#list></categories>

Thanks,
Mike

shikarishambu
Champ in-the-making
Champ in-the-making
Thanks. I just noticed that my search results are not returning any values for custom properties. The search itself is working fine - returning the right set of documents.

Here is the FTL. My content model is called step and pnum, cnum, category(not to be confused with Alfresco categories) and keywords are all part of the content model. How do I reference the custom content model attributes?

<#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">
<html>
<body>
<h3>Step Documents</h3>
<table>
<tr>
<td>Name</td>
<td>Size</td>
<td>Description</td>
<td>Category</td>
<td>PID</td>
<td>SID</td>
<td>TID</td>
<td>Created</td>
<td>Modified</td>
</tr>
<#list stepdocs as row>
<tr>
<td>${row.properties.name}</td>
<td>${row.size}</td>
<td><#if row.properties.description?exists>${row.properties.description!}</#if></td>
<td><#if row.properties["step:category"]?exists>${row.properties["step:category"]?string}</#if></td>
<td><#if row.properties.pnum?exists>${row.properties.pnum!}</#if></td>
<td><#if row.properties.cnum?exists>${row.properties.cnum!}</#if></td>
<td><#if row.properties.keywords?exists>${row.properties.keywords!}</#if></td>
<td>${row.properties.created?string("yyyy-MM-dd HH:mm Z")}</td>
<td>${row.properties.modified?string("yyyy-MM-dd HH:mm Z")}</td>
</tr>
</#list>
</table>
</body>
</html>