Forum Discussion

Fortunato's avatar
Fortunato
Contributor
11 years ago

FreeMarker template error

Hi,   I am trying to render a list of featured topics like so: <#assign featured=rest("/threads/featured?page_size=5").threads /> <#list featured as thread> ${thread.messages.topic.subject}<br /...
  • nathan's avatar
    11 years ago

    The issue you've got is that the 'featured' object is a single node ('threads'), with lots of 'thread' children. So at the moment, instead of iterating over each thread, it's iterating over the single top-level threads node.

     

    'thread.messages.topic.subject' in your code will return a collection of every subject in every thread - which is why you get the error saying it can't convert it to a string.

     

    If you change your code to this, it should work:

     

    <#assign featured=rest("/threads/featured?page_size=5").threads />
    <#list featured.thread as thread>
    ${thread.messages.topic.subject}<br />
    </#list>