This is the events calendar plugin for Snitz Mvc. The calendar is fully-integrated into the forum: all the events are posted as topics. The plugin should be fully compatible with Red1's Event Calendar mod available from SnitzBitz for the classic asp version.
You can download the PLUGIN here
Add the following code wherever you want the link to appear.
You can download the PLUGIN here
Installing the PLUGIN
- Unzip the contents of the downloaded file
- Copy the file in the App_Data folder to your Forums App_Data folder on the webserver
- Copy the SnitzEvents folder and its contents to your Forums Plugins folder
- Open your forum in a browser, Navigate to the Admin/Tools page and use the 'Reset Application' button to recycle the application
Adding a menu link
To add a link to the calendar, open the file /Views/Shared/_Menu.cshtml in a text editor.Add the following code wherever you want the link to appear.
Code:
@if (ClassicConfig.GetIntValue("INTCALEVENTS") == 1)
{
<li>@Html.ActionLink(ResourceManager.GetLocalisedString("mnuEvents", "Menu"), "Index", "Calendar")</li>
}
Installing Admin code
- Install Admin page, open the file /Views/Admin/ModConfiguration.cshtml and add the code below at the end of the file.Code:You can access the PLUGIN config from the Admin|Plugins|Other Plugins menu
@if (Config.TableExists("CAL_EVENTS"))
{
<div class="panel panel-primary panel-body clearfix">
@Html.Action("Admin","Calendar")
</div>
} - To post events, Forums must have a flag set to determine who can post events, To enable this, open the file /Views/Forum/Details.cshtml, scroll down the page until you find the @section Scripts { line, just above that you will see the code belowCode:
<div class="">
<div class="col-sm-6">
@Html.Partial("_FormButtons")</div>
</div>
Edit the section so it appears as below.Code:The following section will appear on the form when editing Forum properties.<div class="">
@if (Config.TableExists("CAL_EVENTS") && ClassicConfig.GetIntValue("INTCALEVENTS") == 1)
{
@Html.Action("ForumEventSettings","Calendar",new {id=Model.Id})
}
<div class="col-sm-6">
@Html.Partial("_FormButtons")</div>
</div>
Add the Event form to the Post Topic form
- Open the file /Views/Shared/PostMessage.cshtml in a text editor.
- Look for the following block of code (around line 190)Code:
@Html.HiddenFor(model => model.CatId)
@Html.HiddenFor(model => model.TopicId)
@Html.HiddenFor(model => model.ReplyId)
@Html.HiddenFor(model => model.Referrer)
@Html.HiddenFor(model => model.IsPoll)
} - Now add the code below directly after the closing } in the code section from aboveCode:
@if (Config.TableExists("CAL_EVENTS") && ClassicConfig.GetIntValue("INTCALEVENTS") == 1)
{
if (Model.Type == PostType.Topic && (User.IsInRole("Administrator") || Model.IsAuthor || User.IsForumModerator(Model.ForumId)))
{
<div class="col-md-3 pull-right hidden-xs hidden-sm" id="cal-container">
@if (Model.TopicId > 0)
{
@Html.Action("TopicEventEdit", "Calendar", new { id = Model.TopicId, page = 1 })
}
else
{
@Html.Action("TopicEvent", "Calendar", new { id = Model.ForumId })
}
</div>
}
} - Scroll down the page until you find the line @section Scripts{ insert the following line below that Code:
@Scripts.Render("~/scripts/snitz.cal.js")
- Continue down the page until you find the line setConditionalValidators();
Insert the javascript code below above the line we just located.Code:Just below the setConditionalValidators(); line you will see the following function
/* Event Calendar code */
$(document).on('click', '#cal-nextevent', function (event) {
var tId = $('#cal-topicid').val();
var fId = $('#cal-forumid').val();
var page = parseInt($('#cal-curpage').val());
event.preventDefault();
$.ajax({
type: "POST",
url: SnitzVars.baseUrl + 'Calendar/TopicEventEdit/' + tId + '/?forumid=' + fId + '&page=' + (page+1),
success: function (data) {
$('#cal-container').html(data);
if ($('#cal-recur').val() == 'EveryDay') {
$('#cal-dow').show();
}
},
error: function (result) {
BootstrapDialog.alert(
{
title: "Error ",
message: result.responseText
});
}
});
});
$(document).on('click', '#cal-prevevent', function (event) {
var tId = $('#cal-topicid').val();
var fId = $('#cal-forumid').val();
var page = parseInt($('#cal-curpage').val());
event.preventDefault();
$.ajax({
type: "POST",
url: SnitzVars.baseUrl + 'Calendar/TopicEventEdit/' + tId + '/?forumid=' + fId + '&page=' + (page - 1),
success: function (data) {
$('#cal-container').html(data);
if ($('#cal-recur').val() == 'EveryDay') {
$('#cal-dow').show();
}
},
error: function (result) {
BootstrapDialog.alert(
{
title: "Error ",
message: result.responseText
});
}
});
});
$(document).on('click', '#cal-update', function (event) {
//debugger;
var serializedForm = $("#cal-editTopicEvent").serialize();
event.preventDefault();
$.ajax({
type: "POST",
url: SnitzVars.baseUrl + 'Calendar/EditEvent',
data: serializedForm,
dataType: "json",
success: function (data) {
$('#cal-container').html(data);
if ($('#cal-recur').val() == 'EveryDay') {
$('#cal-dow').show();
}
},
error: function (result) {
BootstrapDialog.alert(
{
title: "Error ",
message: result.responseText
});
}
});
});
/* Event Calendar code */Code:It may or may not contain other code, just add the following to the end of the function, before the closing }// This function is called after a Topic or Reply is posted
// data contains topic.Id + ":" + ReferrerUrl
function postPostMessage(event,data) {
var arr = data.responseText.split(':');
}Code:Now when posting a topic in forums that allow events, the form below will be visible on the post page.if ($("#cal-addTopicEvent").length > 0) {
postEvent(event, arr);
} else {
window.location.href = arr[1];
}
Adding Calendar icon to topic displays
- \Views\Topic\_MessageButtons.cshtml
- \Views\Shared\DisplayTemplates\Topic.cshtml
Open the above file and look for the lines
<div class="topic-strap">
<span class="hidden-xs">
Add the code below just after those lines.Code:
@if (ClassicConfig.GetIntValue("INTCALEVENTS") == 1)
{
@Html.Action("EventIcon","Calendar",new{id=Model.Id})
}
Open the above file and look for the line <a id="@Model.Id"></a> Add the code below just after the line.
Code:
@if (ClassicConfig.GetIntValue("INTCALEVENTS") == 1)
{
@Html.Action("EventIcon", "Calendar", new {id = Model.Id})
}
