cancel
Showing results for 
Search instead for 
Did you mean: 

SOLVED FreeMarker neasted value :(

joksy
Champ in-the-making
Champ in-the-making
HI to everybody,

I m new to this templating language, and of course it easy encounter some problem.
Ok I post the piece of code,


<#assign Months = {"Gennaio":"01"}+{"Febbraio":"02"}+{"Marzo":"03"}+{"Aprile":"04"}+{"Maggio":"05"}
+{"Giugno":"06"}+{"Luglio":"07"}+{"Agosto":"08"}+{"Settembre":"09"}+{"Ottobre":"10"}+{"Novembre":"11"}
+{"Dicembre":"12"}>


<p style="margin-left:35%; font-size:14px; "> Emissioni di oggi: ${date?string("d MM yyyy")}</p>

<#if companyhome.childByNamePath["Emissioni"]?exists>

<#list companyhome.childByNamePath["Emissioni"].children as x>

<#list x.children as y>
<#assign name_month = y.properties.name>
   
   ${Months.${name_month}?string}
   ${y.properties.name}<br>
   
<#list y.children as doc>
   ${doc.properties["cm:created"]?date?string("d MM yyyy")}<br>
   ${date?string("d MM yyyy")}
   
   <#if doc.properties["cm:created"]?date?string("d MM yyyy") = date?string("d MM yyyy")>
      are equals : ${doc.properties.name} <br>
      <#if doc.properties["{http://www.xxx.com/model/content/1.0}Tema']?exists>
         Tema dell emissione: ${doc.properties["{http://www.xxx.com/model/content/1.0}Tema"]}
      </#if>
   <#else>
      are not equals : ${doc.properties.name} <br>
      
   </#if>      
   
   
</#list>
</#list>
</#list>

</#if>



The problem araise when i m try to get the value of another assignation for get from the hash the value ,

<#assign name_month = y.properties.name>
   
   ${Months.${name_month}?string}

The previous attempts was, but simply tell me that Months.name_moth does not exist, and of course is true. so can i solve this situation.

<#assign name_month = y.properties.name>
   
   ${Months.name_month}


Thanks a lot

Best Regards
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
Try (untested!)
<#assign Months = {
   "Gennaio":1,
   "Febbraio":2,
   "Marzo":3,
   … etc …
   "Dicembre":12
}>
and
${Months[name_month]?string}

Thanks,
Mike

joksy
Champ in-the-making
Champ in-the-making
Hi Mike Thanks for the reply i ve just find the solution 10 sec ago

in fact I use


${Months[name_month]}

Thanks again Have a nice day Smiley Very Happy