elbranscomb
2 years agoExecutive
Trending Messages - Override component questions
I would like to override the Trending Messages (Discussions) component that has the following OOB code. I would like to have this component display the most popular posts on the Home Page, Category or Board page types by both kudos and comments. Is this possible?
I would also for this to not just be a list of hyperlinks to results but include potentially # of comments & kudos or the date of the last comment. Is this possible to add that in.
Here is the OOB code for the component theme-lib.trending-messages that I would like to adapt. Has anyone had success with adapting this to display a more limited time frame and use kudos and comments as the criteria for the results?
<@liaMarkupCache ttl="100000" variation="node" anonymousOnly="true" />
<#include "theme-lib.common-functions" />
<#include "theme-lib.message-macros" />
<#assign targetNodeType = coreNode.nodeType />
<#assign targetNodeId = coreNode.id />
<#assign whereClause = "" />
<#if targetNodeType == "board">
<#assign whereClause = "board.id = '${targetNodeId}' AND " />
<#elseif targetNodeType == "category">
<#assign whereClause = "category.id = '${targetNodeId}' AND " />
</#if>
<#assign pageSize = coreNode.settings.name.get("custom.trending_messages_count", "3") />
<#assign prevTS = .now?date?long-(coreNode.settings.name.get("custom.trending_messages_history_days", "30")?number*24*60*60*1000) />
<#assign whereClause = whereClause + "post_time >= ${prevTS} AND depth = 0" />
<#assign articles = getMessages(pageSize, 0, "id, subject, view_href", whereClause, "kudos.sum(weight) DESC") />
<#if articles?size gt 0>
<@generateComponentContent className="theme-lib-trending-messages" componentTitleKey="theme-lib.trending.messages.title" >
<div class="trending-messages-list">
<#list articles as article>
<div class="trending-message-item">
<a href="${(article.view_href)!""}">${(article.subject)!""}</a>
</div>
</#list>
</div>
</@generateComponentContent>
</#if>