Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Is there a way to make discussion marked as favorite after a post?
Use case:
X starts a new discussion OR X comments a discussion
-> I'd like to make X following this topic automatically
X starts a new discussion OR X comments a discussion
-> I'd like to make X following this topic automatically
Tagged:
0
Comments
If X comments, there is a cool plugin that solves your problem --> http://vanillaforums.org/addon/participated-plugin
I configured Vanilla to send an email when a new comment arrived in a favorite discussion. My main goal is that users receive an email as soon as they are replied to their message.
That's the reason I'd like to automatically "subscribe" users to any thread they comment.
Any other suggestion is appreciated. Thanks.
I think it's a must have feature for small and medium forums.
If it doesn't exist yet, we'll develop it.
change this code at
applications/vanilla/views/post/comment.php
//$ButtonOptions = array('class' => 'Button CommentButton'); $ButtonOptions = array('class' => 'Button CommentButton', 'onclick' =>"if($('a.Bookmark').attr('title') == 'Bookmark'){ $('a.Bookmark').trigger('click') }");
this will trigger the click on * when user hit the post button
I'm on 2.0.13, and the code change is slightly different:
echo $this->Form->Button($Editing ? 'Save Comment' : 'Post Comment', array('class' => 'Button CommentButton', 'onclick' => "if($('a.Bookmark').attr('title') == 'Bookmark'){ $('a.Bookmark').trigger('click') }"));
I also copied the view from applications/vanilla/views/post/comment.php to themes/{my-theme}/vanilla/views/post/comment.php, which makes upgrades a little more resilient.
It should also be noted that this is language dependant since it replies on looking for the title text "Bookmark" on the bookmark link. In our case the link was labelled "Keep me posted" and so that needed to be put into the string instead of "Bookmark". Other languages would need something similar done. There ought to be a way to pick on the translated text so it will always work.
echo $this->Form->Button($Editing ? 'Save Comment' : 'Post Comment', array('class' => 'Button CommentButton', 'onclick' => "if($('a.Bookmark').attr('title') == '" . T('Bookmark') . "'){ $('a.Bookmark').trigger('click') }"));
Just make sure "Bookmark" is translated on the server before it is passed to the page as a JavaScript string. The string probably needs escaping, but this is my lazy attempt that works for me.
application/vanilla/controller/class.postcontroller.php line 199
$this->FireEvent('AfterDiscussionSave');
$this->DiscussionModel->BookmarkDiscussion($DiscussionID, $Session->UserID, $Discussion);//add this line to autobookmark new thread
BTW, I realized that this feature is a standard: FaceBook notifies you by email as soon as someone replies to a conversation you've participated in. Maybe Vanilla should consider to add it in regular options.
Cheers
so the code will only trigger the click if the Star is grey , meaning if the title attribute seen is "Bookmark"
if($('a.Bookmark').attr('title') == 'Bookmark'){ $('a.Bookmark').trigger('click') }
You should double chech in the firebug what the title tag gives you when the dicussion is bookmarked and unbookmarked
you could be using a diff theme?
public function PostController_AfterDiscussionSave_Handler(&$Sender) { $Session = Gdn::Session(); $Discussion = $Sender->EventArguments['Discussion']; $Sender->DiscussionModel->BookmarkDiscussion($Discussion->DiscussionID, $Session->UserID, $Discussion); } public function PostController_AfterCommentSave_Handler(&$Sender) { $Session = Gdn::Session(); $Discussion = $Sender->EventArguments['Discussion']; $Sender->DiscussionModel->BookmarkDiscussion($Discussion->DiscussionID, $Session->UserID, $Discussion); }