Forum Discussion
Hi,
Did you try cloning the 'Subscribe' option from the 'Topic Options' drop-down and display as a button?
Try this -
//Add Subscribe and unsubscribe button in ForumPage, for example:
if(LITHIUM.CommunityJsonObject.Page.name == "ForumPage"){
var element = $(".lia-link-navigation.addBoardUserEmailSubscription").clone();
if(element[0] != undefined){
element = '<div class="custom_board_Subscription">'+ element[0].outerHTML +'</div>';
$(".lia-menu-bar-buttons .lia-menu-navigation").prepend(element);
}
else{
var element = $(".lia-link-navigation.removeBoardUserEmailSubscription").clone();
element = '<div class="custom_board_Subscription">'+ element[0].outerHTML +'</div>';
$(".lia-menu-bar-buttons .lia-menu-navigation").prepend(element);
}
}
Hope this helps!
Thanks,
Srujana.
- ttadej8 years agoAdvisor
Forgot I had posted this question. I ended up creating an endpoint to handle subscriptions for both boards and individual threads. The endpoint takes in the following parameters:
- id
- action (add/remove)
- type (threads/board)
Then it goes something like this:
<#if actionParam == "add"> <#assign response = rest("/${typeParam!?url('UTF-8')}/id/${idParam!?url('UTF-8')}/subscriptions/users/self/add?subscription.type=email") /> <#elseif actionParam == "remove"> <#assign response = rest("/${typeParam!?url('UTF-8')}/id/${idParam!?url('UTF-8')}/subscriptions/users/self/type/email/remove") /> <#else> <#-- handle error -->
My original issue had to do with permissions. In general we've found it is best to do any type of "POST" in an endpoint using ajax.
- gstelang8 years agoMentor
Hey ttadej That's useful.
Is this for subscribing to a label? For example, I create a post and give it a label "Customer Research" and I want to subscribe to this label. Is that something I can do?
- ttadej8 years agoAdvisor
Hi gstelang, I've never used labels and do not see it in their docs. Given that label subscriptions are board-level, my assumption was one could do something like this:
https://$hostname.com/restapi/vc/boards/id/[board_id]/posts/for/labels/text/[label_text]/subscriptions/users/self/add
But that didn't work :(
Related Content
- 4 years ago