Subscribing to a forum

Sam Mueller asked on March 9, 2017 22:59

I'm trying to set up forum subscription in a way where the user can subscribe to the forum name itself rather than the post so that everything underneath this element will notify the subscriber that there is a new thread/post within this forum name.

This is what I'm going for:

Forum Name (ex: Announcements) <<< Subscribe
    Thread/Topic (ex: What we're working on) <<< Anything posted in "Announcements" notifies the subscriber
        Post (ex: Inside the "What we're working on" thread) <<< Anything posted here notifies the subscriber

This is how it's currently set up:

Forum Name (ex: Announcements)
    Thread/Topic (ex: What we're working on)
        Post (ex: Inside the "What we're working on" thread) <<< Subscribe - Anything posted here notifies the subscriber

How do I achieve the first result?

Recent Answers


Trevor Fayas answered on March 10, 2017 00:04 (last edited on March 10, 2017 00:06)

Kentico allows you to subscribe to Forums by default, and you can subscrube at lower levels i believe as well.

https://docs.kentico.com/k10/community-features/forums/managing-forum-subscriptions

The Forums_ForumSubscription table has a ForumID, and an option PostID. A subscription with a ForumID but no PostID is a subscription to the "Forum"

A Thread is nothing more than a Post under the direct Forum (It's a Post that doesn't have a parent Post). The Forum_ForumPost table contains these, and has a NULL for PostParentID if it's the top level (thread). Subscribing to this PostID and it's ForumID would be a subscription to the "Thread"

A Subscription to a post that has a PostParentID, and it's ForumID, would be a subscription to the "Post."

I would take a look at your settings for your Forum, and the webparts, you should be able to subscribe at any of the levels...

0 votesVote for this answer Mark as a Correct answer

Sam Mueller answered on March 10, 2017 14:52

Right, but the issue here for me is that the button/link to subscribe to a forum is missing (I probably should have mentioned this in my original post). The only instance of this is at the post level.

Below image is what I'm trying to achieve:

Image Text

Is there somewhere in the source code or is there a setting I need to check that may have disabled this feature?

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 10, 2017 15:19

Check the Forum Security tab, make sure that subscriptions are allowed there. Make sure also you enable Double-opt-in as this allows subscriptions on multiple levels.

Go to Settings -> Community -> Forums. Check the Enable double opt-in for forums setting. Specify how long you want the confirmation links to be valid in the Double opt-in interval (hours) setting.

Not having these settings may trigger it to not show. So try adding in all the available for it and the Forum itself's settings and see if that does the trick!

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on March 10, 2017 16:33

I think the subscription link is only after you click on one of the forums, you would have to customize that web part and add a button if you want it to display there. Assuming I am looking at the same web part you are using, I only see these options:

<%#GetLink(Container.DataItem, ResHelper.GetString("forums.lock"), "ActionLink", ForumActionType.LockForum)%>
                        <%#GetLink(Container.DataItem, ResHelper.GetString("forums.unlock"), "ActionLink", ForumActionType.UnlockForum)%>

I think if you add this it would work: <%=GetLink(null, ResHelper.GetString("Forums.Forum.SubscribeForum"), "ActionLink", ForumActionType.SubscribeToForum)%>

1 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 11, 2017 02:47 (last edited on March 11, 2017 02:50)

I just added a Forum Group with 2 Forums on my blank Kentico 10 test site, and it is showing a "Subscribe to Forum" once i click into the forum itself. So it's not on the outside, but once you click on the Forum you will see the Subscribe to Forum.

EXPLANATION ( If you don't want to read, just skip to the bottom for solution )

So, the webpart you want to take a look at first is the \CMS\CMSModules\Forums\Controls\ForumDivider.ascx.cs (this is the control that is used in the Forum Group Web Part).

In here there is, in the PageLoad method, a section that detects the Forum's "state" (whether you are looking at the forums, looking at threads, a specific thread, etc). The Switch case for listing all the forums is the "ForumStatusEnum.Forums":

                // Forums
            case ForumStateEnum.Forums:
                ctrl = LoadUserControl(defaultPath + ForumLayout + "/Forums.ascx");
                ctrl.ID = ControlsHelper.GetUniqueID(plcForum, "forumsElem", ctrl);
                break;

So next step is we look at that specific control it's loading, i'm looking at the Tree layout so my control is \CMS\CMSModules\Forums\Controls\Layouts\Tree\Forums.ascx

Zach was close, this is the element that first uses the <%# GetLink %> command Zach told you about. So Zach said to copy this line and place it in the ForumDivider.ascx. HOWEVER, that only appends the special command to subscribe to the forum, but does NOT include the Forum ID in the url.

Ex: Subscribe to Link within forum: /Test-Forum.aspx?forumid=2&subscribeto=0 Subscribe to Link outside forum: /Test-Forum.aspx?subscribeto=0

Notice that the forumid parameter is missing, because the action link just adds the subscribeto=0, and doesn't provide the forum ID.

SOLUTION

THUS, although somewhat of a hack and may 'break' in the future if the url format changes, in order to have a Subscribe link on the OUTSIDE, next to the Forum link, you should modify the Forums.ascx to the below:

<%#GetLink(Container.DataItem, ResHelper.GetString("forums.lock"), "ActionLink", ForumActionType.LockForum)%>
<%#GetLink(Container.DataItem, ResHelper.GetString("forums.unlock"), "ActionLink", ForumActionType.UnlockForum)%>
<!-- BEGIN custom added line -->
<a href="?forumid=<%# Eval("ForumID") %>&subscribeto=0"><%# ResHelper.GetString("Forums.Forum.SubscribeForum") %></a>
<!-- END Added Line -->
<%#AdministratorCode(Eval("ForumID"), "</div>", true)%>

If you notice that i have a manual link that adds the ForumID, and then the &subscribeto=0, this formulated the proper link to then direct the user inside the forum with the action of subscribe.

Image Text

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.