Forum Discussion

jonathancrow's avatar
12 years ago

Subscribe Button

I want to highlight the option to subscribe to a post, thread, or board with a button (instead of having it hidden in the options menu).

 

Does anyone already have code to do that?

 

Thanks,

Jonathan

  • AdamN's avatar
    AdamN
    Khoros Oracle

    Hi Jonathan,

     

    Depending on your requirements, you may be able to leverage the standard components for your purposes. The components just display as links, but if you wanted to you could create a custom component, insert the component(s) using the <@component> FreeMarker macro, wrap the component with your own HTML and style as needed.

     

    Here are the subscription-related components for a thread:

    	<component id="subscriptions.action.remove-thread-user-float" />
    	<component id="subscriptions.action.add-thread-user-float" />
    	<component id="subscriptions.action.remove-thread-user-bookmark" />
    	<component id="subscriptions.action.add-thread-user-bookmark" />
    	<component id="subscriptions.action.remove-thread-user-email" />
    	<component id="subscriptions.action.add-thread-user-email" />

     

    and for a message:

    	<component id="subscriptions.action.remove-message-user-float" />
    	<component id="subscriptions.action.add-message-user-float" />
    	<component id="subscriptions.action.remove-message-user-bookmark" />
    	<component id="subscriptions.action.add-message-user-bookmark" />
    	<component id="subscriptions.action.remove-message-user-email" />
    	<component id="subscriptions.action.add-message-user-email" />

     You'll likely be interested in the "email" ones, but I provided the others just in case. You'll want to make sure you only use these components on pages where they're going to have the appropriate thread/message context (ie. a ForumMessage page)

     

    Alternately, you could use the REST API to add/remove the subscriptions, but that's probably going to be quite a bit more complex. Let me know if you'd prefer to go down that route, and I can provide some additional details to get you started.

     

    I hope this helps!

    • Thank you so much for posting! We've been desperately needing this as most users cannot find the subscription button under "page options." I'm not an engineer, so I'm not able to use the Lithium SDK with any amount of confidence. Greatly appreciated!

      • jjeremiah's avatar
        jjeremiah
        Expert

        I've been following this thread and haven't yet got this to work.

         

        Same issue / question - we want to make it easy for a user to subscribe to the message or perhaps the thread.


        I've explored using the API... but consistently get a 501 errorr code when I use the POST method.

         

        For example: 

        <form action="https://community.xxx.com/restapi/vc/boards/id/tips_and_tricks /subscriptions/users/self/add/email" method="post"><input type="submit"> <!-- Press this button to submit form --></form>
        <response status="error">
        <error code="501">
        <message>
        Unknown path element at node 'node_subscription_context.users.self.add'.
        </message>
        </error>
        </response>

        I get the same result for:

        <form action="https://community.xxx.com/restapi/vc/threads/id/1615100/subscriptions/users/self/add/email" method="post"><input type="submit"> <!-- Press this button to submit form --></form>

         

        Any ideas or feedback?   


        Thanks


        John

    • LainieH's avatar
      LainieH
      Expert

      AdamN this was extremely helpful. I'm 1/2 way there - I created the custom component, added the OOTB component code, wrapped a little HTML around it and even added a couple of CSS styles. cjdinger refined it.. but we're missing one thing.

       

      We want to add the Subsribe button for a board within the 

      "lia-menu-bar lia-menu-bar-top lia-component-menu-bar" class (vs. adding the button using a fixed position in CSS).

       

      Is this possible?

       

      Thank you, Lainie 





       

      • matthew_d's avatar
        matthew_d
        Mentor

        Bump this post. LainieH did you ever find the answer to this? AdamN could you provide some additional support here? I have the same question.

    • Inactive User's avatar
      Inactive User

      Is there a component like these for the email subscription from a board page? THanks

      • Inactive User's avatar
        Inactive User

        Nevermind. Found it. Just replaced 'message' or 'thread' with 'board'. Thanks!