getting a module to disappear itself when it's empty
I have a piece of custom content that serves as an unsolved threads module. Works great except that once everything's solved, it's an ugly, empty, useless box.
I am trying to figure out how to code an ITE statement that says "If this is empty, self-destruct the custom content module."
The part I am stuck on is determining how it's empty.
The call being made to get the results is:
<#assign rest_query = "/boards/id/*my node id*/search/messages?openresponse=true&sort_by=-topicPostDate&include_forums=true&page_size=" + results_list_size/>
What do I need to make as the criteria in the IF statement for "If *whatever this is is empty*..."
It looks like you are relying on the "forums.widget.message-list-panel" component to do the actual REST query, and you want to determine before rendering that component whether or not to display it. You could use the same query, but with a /count at the end of the path, to determine if there will be any results -- something like this:
<#assign rest_count_query = "/boards/id/ent5/search/messages/count?openresponse=true&sort_by=-topicPostDate&include_forums=true&page_size=" + results_list_size/> <#assign rest_count = rest(rest_count_query).value /> <#if rest_count?number gt 0> <#-- call the forums.widget.message-list-panel component --> </#if>
- There is ?solved=true but that will only return you solved threads. It is a filter on all messages. Unfortunately, that means that ?solved=false doesn't get you all unsolved threads. It just gets you all threads (same as what you have without anything in the query string). I would add an idea to have either ?solved=false return unsolved threads or a new filter ?unsolved=true.