Kentico Xperience 活动 - 如何添加新活动

问题描述

Kentico 13 MVC 核心站点构建

成功安装:

事件正在 Intranet 场景中使用。寻找允许员工在不登录 Kentico CMS 的情况下将新事件添加到日历的最佳方法。 (类似于 Kentico 12 CMS 门户引擎中的事件预订系统)

我在日历下方创建了一个带有事件字段的表单,但无法找到可填充下表的插入语句:

  • 体验活动
  • 内容管理系统树
  • CMS 文档

仅供参考:第一个 MVC 核心项目

提前致谢

解决方法

查看 NuGet 包中包含的 page type classes and providers,您可以使用以下代码在事件日历页面下插入一个新页面。

        var parentPage = EventCalendarProvider.GetEventCalendars()
            .TopN(1)
            .Culture("en-GB")
            .Published()
            .LatestVersion()
            .FirstOrDefault();

        var newEvent = new Event
        {
            EventName = "Test Event",EventSummary = "Summary Text",EventDescription = "Test Description",EventLocation = "Somewhere",EventStart = DateTime.Now,EventIsAllDay = true,// ...etc for the rest of the properties coming from the Kentico Form you've created.
        };

        newEvent.Insert(parentPage);

如果您还没有探索过,您可以使用 BizFormItemEvents 拦截表单提交并使用上述代码插入页面。