Forum Discussion
Hi qinglau ,
Let me just clarify my understanding. You would like to display 4 blog topics and exclude featured blog article from it. If my understanding is correct , this might be of help.
<#assign featuredThreadId = rest("/blogs/id/cs_blog/threads/featured").threads.thread.id />
<#assign blogList = rest("/blogs/id/cs_blog/topics").node_message_context />
<#assign counter = 0 />
<#assign limit = 4 />
<ul>
<#list blogList.message as blog>
<#if blog.id!=featuredThreadId && (counter< limit-1)>
<#assign counter = counter?number +1/>
<li>${counter} ${blog.subject} <br/></li>
</#if>
</#list>
</ul>
The above snippet is under the assumption , there would be only one featured article. If there might be more than one , we would have to change the code a bit.
Since I have initialized the counter as 0 , I have checked for limit-1 .
You can improvise on this.
Hope that helps.
Thanks,
Sam
Hi Guys,
thank you for the replying. During few days testing, i found out that two main issues in my current solutions.
1. When i am build the list of articles via my REST API call:
<#assign AllblogArticles = rest("${rootPath}/topics?restapi_response.style=view").node_message_context />
The limit of this REST API call is 25 articles. Since we have more than 25 articles in our blog.
2. Next step, i create an new array and stores all the articles into an array
<#assign articles=[]>
<#list AllblogArticles.message as msg> <#if msg.id!=featuredID> <#assign articles = articles + [ msg ] /> </#if> </#list>
If there are plenty of users accessing our blog, we will have memory issues.
Still looking for a better way.
Cheers,
Qing
Related Content
- 11 years ago