2 YEARS AGO

Content management tweak

One of the cool features of Kentico being a platform is that you can extend it quite easily and add cool features without having to code. In this post I will show you how you can enhance content management and provide recorded form data at the page level.

Before we begin our journey I want to point out that the steps in this post are far from optimal and have not been tested thoroughly. The purpose of this post is to show you easy you can tweak the system and apply custom functionality. My personal goal is to leverage this customization feature and introduce several enhancements in future projects of our clients. I recommend you to follow my blog to get updates on my experiences :)

Step 1: Configure the page type

The first thing that we are going to do is create a new page type and add some fields:
  • Create new page type called: Contact (namespace: Custom)
  • Add a ContactName text field and mark it required
  • Add a ContactForm integer field, query the forms assigned to the current site and present it as a drop down list:
SELECT [FormID], [FormDisplayName] FROM [CMS_Form] WHERE [FormSiteID] = {% CurrentSite.SiteID %}
  • Go through the next steps and finish the wizard

Step 2: Create the user interface

Up next is the creation of the user interface via the following steps:
  • Create a new module called: Content management enhancements
  • In the "User interface" section create a new element within "CMS" --> "Administration" --> "Content Management" --> "Pages" --> "Edit" called: "Recorded data"
  • Select the "URL" type as element content and add the following target URL:
~/CMSModules/BizForms/Tools/BizForm_Edit_Data.aspx?formId={% Documents.ClassNames("Custom.Contact").Where("NodeID = " + QueryString.nodeid).WithAllData.FirstItem.GetValue("ContactForm") %}

The macro at the end will grab the document using the NodeID and pass in the FormID from the selected contact form.
  • Add a visibility condition:
CurrentUser.IsAuthorizedPerResource("cms.form", "ReadData") && Documents.ClassNames("Custom.Contact").Where("NodeID = " + QueryString.nodeid).FirstItem != null

Step 3: View the result

If you have followed the previous steps carefully then you should be able to create a new contact page in the content tree with option to select a form:

New contact page

After creation notice that the "Recorded data" tab is available from within the content tree:

Recorded data in the content tree
This tweak introduces an exciting way of integrating existing features and making them available directly in the content tree.

Until we meet again!