Forum Discussion
Hi Luis,
There's a freemarker builtin that you should be able to use:
http://freemarker.sourceforge.net/docs/ref_builtins_sequence.html#ref_builtin_sort_by
Putting it all together, it might look something like this:
<#list rest("/boards/style/blog/nested").boards.board?sort_by("title") as board> <#-- Do stuff --> </#list>
I hope this helps!
Hi Adam,
The built in is working just fine. I'm now facing a REST API call issue.
I'm trying to retrieve certain Community's blog list with
<#assign global_blogsCount = rest('boards/style/blog/nested/count').value/>
However, when I try to use this value for a very simple calculation such as
<#assign leftColumnEnd = (global_blogsCount/2) />
I get the following error.
Expression global_blogsCount is not numerical
Could you please advice?
Gracias,
Luis
- AdamN13 years agoKhoros Oracle
As far as freemarker is concerned, the value you're getting back is a string. So if you want to use it as a number, you need to convert it. There's a "number" built-in that can be used with strings. For example:
<#assign global_blogsCount = rest('boards/style/blog/nested/count').value?number />
In case you're curious, you can find a full listing of the available freemarker built-ins here:
http://freemarker.sourceforge.net/docs/ref_builtins.html
I hope this helps!
-Adam
- lc-garcia13 years agoGuide
Thanks Adam,
That worked out the issue. Could you please point out what's wrong on this snippet?
<#if (global_blogsCount % 2) == 1)>
<#assign leftColumnEnd = (leftColumnEnd?int) + 1 />
<#/if>
<#list global_blogs.board?sort_by("title") as blog>
<#if gblogIdx != 0>
<#if (gblogIdx == (leftColumnEnd + 1) >
<#assign blogMenuContentAlpha = blogMenuContentAlpha + '</div><div class="hp-sub-nav-row blog-list-right">' />
<#/if>
</#if>
<#assign blogMenuContentAlpha = blogMenuContentAlpha + '<div class="hp-nav-col"><ul><li><a href="${blog.@view_href}">${blog.title}</a></li></ul></div>' /> <#assign gblogIdx = gblogIdx + 1 />
</#list>Lines in bold are breaking my code
Gracias,
Luis
- AdamN13 years agoKhoros Oracle
It looks like the second bolded line of code has an unmatched parenthesis, so that could be one issue. Does fixing that resolve everything? If not, could you reply back with the details of the error message you're receiving?
Related Content
- 4 months ago
- 3 years ago
- 2 years ago
- 2 years ago
- 2 years ago