You need to sign in to do that
Don't have an account?
MCord
How can you retrieve a list of Community Navigational Topics in APEX?
The Topic Catalog Component proves that it is possible to create a component that lists out just the nav topics. How do we replicate this?
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_ConnectAPI_ManagedTopics_static_methods.htm#apex_ConnectAPI_ManagedTopics_static_methods
Below is a reference to return a list of Navigation Topics defined in your community. Create a TopicController class referencing the methods listed in the url above.
All Answers
I think it is not supported. Vote for this idea - https://success.salesforce.com/ideaView?id=08730000000cFIAAA2
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_ConnectAPI_ManagedTopics_static_methods.htm#apex_ConnectAPI_ManagedTopics_static_methods
Below is a reference to return a list of Navigation Topics defined in your community. Create a TopicController class referencing the methods listed in the url above.
In your APEX Controller for your component add this function.
@AuraEnabled
public static List<ConnectApi.Topic> getNavigationTopics(){
ConnectApi.ManagedTopicCollection mtCollection = ConnectAPI.ManagedTopics.getManagedTopics(commId, ConnectApi.ManagedTopicType.Navigational);
List<ConnectApi.Topic> topicList = new List<ConnectApi.Topic>();
for(ConnectApi.ManagedTopic mtopic : mtCollection.managedTopics)
{
topicList.add(mtopic.topic);
}
return topicList;
}
loadTopics: function (component, event, helper) {
action.setCallback(this, function(response){
var state = response.getState();
if(state==="SUCCESS"){
var responses = response.getReturnValue();
component.set("v.managedTopics", responses);
} else {
console.log("error occured retrieving topics");
}
});
$A.enqueueAction(action);
}
Then in your component add this.
<aura:attribute name="managedTopics" type="ConnectApi.ManagedTopic[]" />
<aura:iteration items="{!v.managedTopics}" var="topic">
{!topic.name}
</aura:iteration>
==================================================================================================
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" controller="CommunityHelper">
<aura:attribute name="managedTopics" type="ConnectApi.ManagedTopic[]" />
<aura:handler name="init" value="{!this}" action="{!c.loadTopics}"/>
<aura:iteration items="{!v.managedTopics}" var="topic">
{!topic.name}
</aura:iteration>
</aura:component>