CONTENTSTART
EXCLUDESTART EXCLUDEEND

Kentico 12 MVC Boilerplate

The transition from Portal Engine to MVC can be challenging for many who are new to MVC.  Many of the features we were accustomed to having through webparts now require coding to enable or add them in.  Kentico provided the Dancing Goat site in MVC to showcase many of their features, but the down side is there's too much in it, it's very hard to "strip" out the Dancing Goat and preserve the Kentico features so you can start a new project.

Sadly the "Blank MVC Site" goes to the other extreme, it's truly Blank.  There's nothing in it, no Authentication OWIN setup, no routes or helpers, no 404s handlers, no bundles, no nothing.  Leaving a first-time developer going through a lot of documentation to get things started.

A Better Boilerplate

As I've worked on my own personal site and worked on integrating key features and helpers into my MVC site, I've slowly built a base set of tools.  I've then taken these tools and created a Kentico 12 MVC Boilerplate project on GitHub.  The reason for putting it on GitHub is because I really wanted this boilerplate to be a community project, where people can contribute things like useful helpers, examples, and much needed Inline Editors, Widgets, Sections, and more.  

You can fork the repo at https://github.com/KenticoDevTrev/KenticoBoilerplate_v12.

Installation

The installation steps are on the Repo's main page, and although there probably won't be a large number of database changes, Kentico Continuous Integration is leveraged so you can do a CI-Restore once you have the base database installed and hooked up in order to get any changes that occurred since the initial push.  I have included a powershell and a bash file that makes this easy, just requiring you to add in the path to the installation and your IIS app pool name.  If you run into any issues, just tell me.
You can also leverage the .gitignore file and setup of the web.config to better handle putting your Kentico projects into your own GIT repo, such as Azure Dev Ops.

Current Features

App_Start

The boilerplate comes with the following App_Start features enabled:

  1. Page Builder Enablement
  2. jQuery, jQuery Validate and jQuery Ajax Unobtrusive bundles (used in Client-Side form validation and Ajax simplification)
  3. OWIN Authentication for Kentico setup
  4. Routes with the Kentico required route, Dynamic routing for NodeAliasPath routing, normal Routing and 404 handler.

Bootstrap and jQuery

The instance includes Bootstrap 4 CSS and Javascript and jQuery libraries (including the Kentico libraries needed to run the Page Builder.

Helpers

I've included some Helper classes, including a sample BaseController with a SetContext(DocumentID) method that allows you to add CurrentDocument, CurrentCulture, CurrentSite properties in the ViewBag.

DocumentQueryHelper is a class that mimics the Repeater/Hierarchy Repeater, allowing you to easily retrieve TreeNodes.  Caching is automatically handled for you.  It also has a helper to find Nodes based on the NodeAliasPath (checking Aliases as well).

DataQueryHelper mimics the Repeater with Custom Query, allowing you to use CMS Queries and get the data back, again Caching is handled and Query Parameters supported.

EnvironmentHelper grants access to things such as the AuthenticatedUser, if Preview is Enabled, etc.
KMVC Route class which is used in route handling based on the URL instead of hard set paths.
Sample Widgets, Section, and Inline Editor

I've included a 'bare bone' set of widgets, sections, and Inline editors.  Little more than an input and an output for the widgets, these are great to clone and create your own.  They show both a widget using an Inline Editor, and one using the dialog screen.  Same for the Section and Inline Editor.  I do plan on importing the Inline Editors that come with the Dancing Goat site eventually (Hey, maybe you can do that yourself and create a pull request!)

Master Page, Home Page, Login

I've included a Bare-Bones Master Page (Shared Layout), Home Page, and Login Control/Action/Views.  These don't have any fluff, just the bare minimum to have Kentico's features enabled, and Bootstrap and jQuery included since these are often needed for the example pages.  The login page provides a very basic Login screen and is properly hooked up into Kentico's OWIN authentication.

Examples

There is an Examples Controller and Pages that show you how to mimic "Web Parts" in a couple different ways.  One uses the Model View-View Model approach, one uses pure context (ViewBag), one uses more of a Property type of approach.  This should help you start out!

By the way, feel free to modify the Examples Controller and put in your own Actions and Views for useful example situations for others to benefit from.

Relationships Extended

I've included my Relationships Extended module in the Kentico CMS portion of the site, and the Relationships Extended MVC Helper in the MVC Project.  Keep in mind if you don't want these, just remove the nuget packages.

Wrapping it Up

As always, i do my best to help other developers create better sites and leverage Kentico to it's max.  I hope that this tool will help you all get a good start and really take off with MVC.  If you have other ideas or recommendations, please tell me.  

Comments
Blog post currently doesn't have any comments.
= seven - two
CONTENTEND