Exclude topic in REST API response
Hello Guys,
I am working on a custom componment which will display list of blog articles under one category node. I am using a REST API call to get all topics from the specifc catergory. For example:
http://qszwf76546.stage.lithium.com/restapi/vc/categories/id/Blog/topics?restapi_response.style=view.node_message_context
I create my own array object and try to iterator the response result from my REST API call to exclude the feature topic id.
<#assign articles=[]> <#assign totArticles = 4 /> <#assign counter = 1 /> <#-- Exclude hero article from blogArticles list--> <#assign AllblogArticles = rest("${rootPath}/topics?restapi_response.style=view").node_message_context /> <#assign featuredID = latestFeatured(coreNode.id) /> <#list AllblogArticles.message as msg> <#if msg.id!=featuredID> <#assign articles = articles + [ msg ] /> </#if> </#list>
The lastestFeatured is the function that gets the lastest featured id.
After my own array is done and exclude the featured topic in my REST API response results. I am using my own arrray "articles" to display my results in HTML . I lmisted it that will only show 4 results in once
<#list articles as msg> <li class="tiles-tile"> <@component id="custom-kpncoblog-article" hero="false" message=msg slim=is_slim/> </li> <#if counter == totArticles> <#break/> <#else> <#assign counter = counter + 1 /> </#if> </#list>
However, i find out that there is an empty content array in my custom array object. It brings me an empty component.
I think it is the something wrong during my own arrray creation process. The if condition code(
<#if msg.id!=featuredID>
) skips the content of the specific topic , but my own array just create an index for that.
I am wondering whether someone has a better solution or advice ?
Thank you