Liam,
I have added a breakpoint at the basePageTemplate controller and added a new route to that controller. The break point isn't being hit. Here is the code:
PageTemplateProperites.cs
using Kentico.Forms.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc.PageTemplates;
namespace AE.Web.Gwic.Models.PageTemplates
{
public class PageTemplateProperties : IPageTemplateProperties
{
[EditingComponent(CheckBoxComponent.IDENTIFIER, Order = 0, Label = "Show Header")]
public bool? ShowHeader { get; set; } = true;
}
}
PageTemplateController
namespace Kentico.PageBuilder.Web.Mvc.PageTemplates
{
//
// Summary:
// Base class for Page builder page template controller with custom properties of
// type TPropertiesType.
public abstract class PageTemplateController<TPropertiesType> : ComponentController<TPropertiesType> where TPropertiesType : class, IPageTemplateProperties, new()
{
//
// Summary:
// Creates an instance of Kentico.PageBuilder.Web.Mvc.PageTemplates.PageTemplateController`1
// class.
protected PageTemplateController();
//
// Summary:
// Creates an instance of Kentico.PageBuilder.Web.Mvc.PageTemplates.PageTemplateController`1
// class.
//
// Parameters:
// propertiesRetriever:
// Retriever for page template properties.
//
// currentPageRetriever:
// Retriever for current page where the page template is used.
//
// Remarks:
// Use this constructor for tests to handle dependencies.
protected PageTemplateController(IComponentPropertiesRetriever<TPropertiesType> propertiesRetriever, ICurrentPageRetriever currentPageRetriever);
}
}
BaseTemplateController.cs
using Kentico.PageBuilder.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc.PageTemplates;
using Kentico.Web.Mvc;
using System.Linq;
using System.Web.Mvc;
namespace AE.Web.Gwic.Controllers
{
public class BasePageTemplateController : PageTemplateController<PageTemplateProperties>
{
/// <summary>
/// A GET action displaying the page where you wish to use page templates.
/// </summary>
/// <param name="pageAlias">Page alias of the displayed page.</param>
public ActionResult Index(string pageAlias)
{
// Retrieves the page from the Kentico database
TreeNode page = DocumentHelper.GetDocuments()
.WhereEquals("NodeAlias", pageAlias)
.OnCurrentSite()
.TopN(1)
.FirstOrDefault();
// Returns a 404 error when the retrieving is unsuccessful
if (page == null)
{
return HttpNotFound();
}
// Initializes the page builder with the DocumentID of the page
HttpContext.Kentico().PageBuilder().Initialize(page.DocumentID);
// Returns a TemplateResult object, created with an identifier of the page as its parameter
// Automatically initializes the page builder feature for any editable areas placed within templates
return new TemplateResult(page.DocumentID);
}
}
}
TwoColumnPageTemplateController.cs
using AE.Web.Gwic.Controllers.PageTemplates;
using Kentico.PageBuilder.Web.Mvc.PageTemplates;
using System.Web.Mvc;
[assembly: RegisterPageTemplate("AE.Gwic.Web.PageTemplates.TwoColumnPageTemplate", typeof(TwoColumnPageTemplateController), "Two Column Page")]
namespace AE.Web.Gwic.Controllers.PageTemplates
{
public class TwoColumnPageTemplateController : BasePageTemplateController
{
public ActionResult Index()
{
return View("PageTemplates/_TwoColumnPageTemplate");
}
}
}
RouteConfig.cs
using Kentico.Web.Mvc;
using System.Web.Mvc;
using System.Web.Routing;
namespace AE.Web.Gwic
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Maps routes to Kentico HTTP handlers and features enabled in ApplicationConfig.cs
// Always map the Kentico routes before adding other routes. Issues may occur if Kentico URLs are matched by a general route, for example images might not be displayed on pages
routes.Kentico().MapRoutes();
routes.MapRoute(
name: "Templates",
url: "{pageAlias}",
defaults: new { controller = "BasePageTemplate", action = "Index" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
This gives me a 500 error