Create a custom page
Describes how to create a custom page in Configured Commerce Classic CMS.
For more background information on building pages and the components to CMS, refer to the article on Extend pages.
-
Add a class library to the Configured Commerce solution
-
Add a new class called
CustomPage
that derives fromContentPage
and implements theICreatableContent
interface.public class CustomPage : ContentPage, ICreatableContent { }
-
Add a new class called
CustomPageContentCreator
that implements theAbstractContentCreator
with a generic type ofCustomPage
. The interface will require theCreate()
method. -
Initialize the
CustomPage
to one of the menu items in the CMS, such as the Home page. Provide the name, title, url and save the item to the content creator.public class CustomPageContentCreator : AbstractContentCreator<CustomPage> { protected override CustomPage Create() { var now = DateTimeProvider.Current.Now; var customPage = this.InitializePageWithParentType<CustomPage>(typeof(HomePage)); customPage.Name = "Custom Page"; customPage.Title = "Custom Page"; customPage.Url = "/CustomPage"; customPage.ExcludeFromNavigation = true; this.SaveItem(customPage, now); return customPage; } }
-
Create a new folder called CustomPage. The naming convention here will map directly the
ContentPage
class name. -
Add a new MVC view to the Theme/ThemeName/Views/Pages/CustomPage folder called Standard.
-
Use the
CustomPage
as the model and save changes. -
Add the custom library as a reference to the B2B Commerce.Web project.
-
Rebuild the solution and view the Configured Commerce CMS in the browser.
Page model and content objects
The CurrentPage
property will retrieve the current page. The Content
property is a helper object that allows retrieval of the page, children, widgets etc.
These are properties that are defined on the WebViewPage
. The WebViewPage
is the model for the view, so in a view it can use @CurrentPage
and @Content.GetChildPages(CurrentPage.ContentKey)
.
Templates
Templates are, structurally, predefined pages with zones embedded into the HTML markup. Use templates to create consistent layout for pages and content. At the core, templates are built leveraging MVC views placed in the Views > Content > TemplatePage. These views are then picked up at runtime to populate the menu items in the Add Template action panel.
Templates can support any widget. It is common to use the Template - Zone widget so that when pages are created from the template, those newly created pages can support additional widgets.
Updated over 1 year ago