sullysnack
12 years agoKhoros Alumni (Retired)
REST call for "Is the accepted-solutions feature enabled?"
Can Freemarker in a custom component check whether the board of the topic page has the accepted-solution feature enabled or not?
Say some boards in my community have the accepted-solutions feature enabled. Some boards have it disabled. I want to add a component to the topic-page quilt for all topic pages. In this component I want to query the number of solutions for the board of the current topic.
In REST calls for board information which contain /solutions in the path, when the accepted-solution feature is disabled I see server parse error:
"A required feature is not enabled: accepted-solutions."
Example code... Board AAA has the Aceepted Solutions feature enabled but BBB does not...
<#assign foo = -1 />
<#assign foo = rest("/boards/id/AAA/solutions/count").value />
<#assign foo2 = -1 />
<#attempt>
<#assign foo2 = rest("/boards/id/BBB/solutions/count").value />
<#recover>
</#attempt>
The foo2 call bombs the page even like this inside an attempt block.
To avoid the parser error I'd rather not hardcode the ids of the boards which have the AS feature disabled. Admins can change this setting at any time for any board.
Any ideas?
Thanks,
Dave
Hi Dave,
We store things like that as a "setting" for the node. This particular setting is called config.enable_accepted_solutions. There are REST API calls to get settings for a node (community, category, board/blog/idea/etc).
Give this a try:
/boards/id/AAA/settings/name/config.enable_accepted_solutions
I hope this helps!