Hey,
we've done something like this for a standing alone subscribe and unsubscribe btns
custom subscribe button component for articles and blogs
<#import "theme-lib.common-functions.ftl" as common />
<#if !user.anonymous>
<#import "common-functions" as utility />
<#attempt>
<#if page.name == 'BlogArticlePage' || page.name == 'TkbArticlePage'>
<#assign id = page.context.thread.topicMessage.uniqueId!'' />
<#assign substype = "threads">
<#else>
<#assign id = coreNode.id!'' />
<#if page.name == "BlogPage">
<#assign substype = "blogs">
<#elseif page.name == "TkbPage">
<#assign substype = "boards">
</#if>
</#if>
<#assign checkSubscription = rest("/${substype}/id/${id}/subscriptions/users/self/type/email").subscription />
<#if checkSubscription.id?has_content>
<a class="lia-link-navigation unsubscribe-btn" <#if user.anonymous>disabled="disabled"</#if> id="unsubscribe-btn" href="javascript:void(0);">
<span class="lia-button lia-button-primary">Unsubscribe</span>
</a>
<#else>
<a class="lia-link-navigation subscribe-btn" <#if user.anonymous>disabled="disabled"</#if> id="subscribe-btn" href="javascript:void(0);">
<span class="lia-button lia-button-primary">${text.format("custom.subscribe-text")}</span>
</a>
</#if>
<#assign endpointUrl = common.getEndpointUrl("custom-subscribe-blogs") />
<@liaAddScript>
(function($) {
$(document).ready(function() {
$('.subscribe-btn, .unsubscribe-btn').click(function() {
var bId = '${id?js_string}';
var substype = '${substype?js_string}';
var classbtn = $(this).attr('id') || '';
$(this).attr('disabled', 'true');
$.ajax({
url: '${endpointUrl}',
data: {'Id': bId, 'ClassBtn': classbtn, 'substype': substype},
type: 'post',
success: function(data) {
location.reload();
}
});
});
});
})(LITHIUM.jQuery);
</@liaAddScript>
<#recover>
<!-- error in custom-subscribe-blog -->
</#attempt>
</#if>
calling endpoint component in the code above
<#compress>
<#import "theme-lib.common-functions.ftl" as common />
<#if user.registered && common.validEndpointRequest(false, true,false)>
<#setting url_escaping_charset="UTF-8" />
<#setting number_format="0.######" />
<#assign ID = http.request.parameters.name.get("Id", "") />
<#assign Class = http.request.parameters.name.get("ClassBtn", "") />
<#assign substype = http.request.parameters.name.get("substype", "") />
<#if user.anonymous || (ID?length lt 1) || (Class?length lt 1) || (substype?length lt 1)>
<p>Not permitted</p>
<#else>
<#if Class == "subscribe-btn">
<#assign subscribed = restadmin("/${substype}/id/${ID}/subscriptions/users/self/add?subscription.type=email") />
${subscribed.@status}
<p>Subscribed successfully</p>
<#elseif Class == "unsubscribe-btn">
<#assign subscribed = restadmin("/${substype}/id/${ID}/subscriptions/users/self/type/email/remove") />
${subscribed.@status}
<p>UnSubscribed successfully</p>
</#if>
</#if>
</#if>
</#compress>
definitely needs some css, we have our css and scheme , you should code yours