cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker using association for avatar

singleton
Champ in-the-making
Champ in-the-making
Hi,

I was trying the following code to indicate via webscript an user has uploaded his avatar or not:
<#if node.assocs["cm:avatar"]?is_collection && node.assocs["cm:avatar"]?size &gt; 0>"avatar": "y",<#else>"avatar": "n",</#if>

node is of type cmSmiley Tongueerson, the above association gives an error:
freemarker.core.InvalidReferenceException: Expression node.assocs["cm:avatar"] is undefined on line 25, column 14 in tdc/node.inc.ftl at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)

According the contentmodel the 'avatar' association is correct, how to solve this issue?
1 REPLY 1

singleton
Champ in-the-making
Champ in-the-making
Found it, because some avatars are not available, the association also doesnt exist

<#if node.assocs["cm:avatar"]?exists && node.assocs["cm:avatar"]?size &gt; 0>"avatar": "y",<#else>"avatar": "n",</#if>

does the job.

Thnx  :wink: