Forum Discussion
DougS
10 years agoKhoros Oracle
That seems like a good approach. The only optimization I might recommend is to use a LiQL query instead so you can limit the amount of data that needs to be retrieved and processed -- something like this should do the trick:
<#if page.context.thread??>
<#assign query = "SELECT id FROM messages WHERE topic.id = '" + page.context.thread.topicMessage.uniqueId + "' AND is_solution = true" />
<#assign resp = rest("2.0", "/search?q=" + query?url) />
<#assign seqSolutions = []>
<#list resp.data.items as solution>
<#assign seqSolutions = seqSolutions + [solution.id]>
</#list>
<#if (seqSolutions?size gt 0)>
<meta name="solutions" content="${seqSolutions?join(",")}" />
</#if>
</#if>
(I would of course also reccomend that you put in proper error handling for your rest v2 calls, as we write about in the Error handling in FreeMarker with Community API v2 article)
-Doug
DougS
10 years agoKhoros Oracle
Going along with the last reply I made, the custom component mentioned in the topic message could be re-written using LiQL as follows:
<#if page.context.thread??> <#assign resp = rest("2.0", "/messages/" + page.context.thread.topicMessage.uniqueId + "?fields=conversation(featured)") /> <#if resp.data.conversation.featured> <meta name="featuredtopic" content="yes" /> </#if> </#if>
Related Content
- 4 years ago
- 9 months ago
- 14 years ago