Since the earliest days of DNN, users have had the ability to create user defined tables for storing structured content. The original UDT module was eventually renamed to the Form & List module and continued to be enhanced for many years to provide greater control over the data definition and presentation. Over the past couple of years there have been a few other Open Source modules that have tackled the job of providing structured content editing for DNN. I have long believed that this is a fundamental requirement of any CMS and should be an out of the box capability for the platform.
I’m pleased to announce that DNN 8 will once again include the ability to create, edit and display structured content as a native capability of the platform. DNN 8 CTP 5 for the first time includes both the Dynamic Content Type Manager and the Dynamic Content Viewer. These two modules, along with an improved Content API, make up the new Dynamic Content Creator (DCC).
In the past users have often resorted to modules like the Announcements module, the FAQ module, the List module and many others that can be easily replaced with the DCC. Let’s take a look at what is shipping with CTP 5 and what we still have left to complete for DNN 8.
Getting Started
To get started with DCC, first lets login as an administrator and go to the Dynamic Content Type Manager in the Admin menu:
This will open up the type manager, the heart of the DCC, which we use for managing content types. In CTP 5, DCC ships with four basic content types: HTML, Markdown, Employee and Product. These content types will likely change as we finish work on adding list and reference type support to the platform.
Editing a content type allows you to view and modify the underlying structure. Content fields allow you to create rich content structures and will be used when viewing and editing content to determine how to present the underlying data and what content editors should be shown for creating or updating content. Content Types like HTML or Markdown are simple, single field types which are useful when we just want to put some unstructured content on a page. Ultimately, you could use the HTML content type as a simple replacement for the HTML module.
Content fields can be defined using any of the pre-defined data types, or we can create a new data type. This is very useful for those times when you want to offer a custom editing experience but don’t want to affect other content types which may already rely on a specific editor. For example, the built in Date type uses a jQuery UI based Date picker, but you might want to define a date range data type with a custom editor that uses something like the date range picker in Google Analytics shown below.
The DCC includes 15 different data types in CTP 5, but I expect that we’ll expand this number before DNN 8 finally ships. We’ll also be tweaking some of the underlying base types which define how the data is serialized. Currently some of the types like Images and Files are stored as integers which are easily related to files in the DNN file system, but we are likely to change the underlying type to string so that we can store references to files or images which may exist outside of DNN.
Templates, Templates, Templates
Templates play an important role in DCC. Templates are used to define how your data should be presented and how your content is edited. The Dynamic Content Type Manager includes a built in template editor for creating and updating templates. You can define view templates and edit templates so that you can control all aspects of how your content type is shown. In the current CTP, we have included basic snippet support to aid in developing templates. We’ll be adding a lot of new templates before the final release which should make creating templates even easier. CTP 5 currently supports Razor Script templates. We are planning to add support to Token based html templates as many site owners will not want to give Razor Script access to anyone who isn’t a host user.
Below the basic view and edit templates there exists an entire set of Display and Editor templates. These templates define exactly how to render a given data element depending on whether you are in edit mode or display mode. For example, although an image might be stored as a number in the database, you will want that displayed as an <img> tag in the final output. The Display and Editor templates are where this magic happens. We’ll go over where these templates are stored and how they work in a separate blog post.
CTP 5 also includes two special templates. There is a getting started template which defines what to show the user before they have fully configured the Dynamic Content Viewer. This template is fully editable by administrators so that they can provide content managers with site specific instructions for using content types. The second template is a system template that is used for auto-generating the editing view. You can use this edit template with any content type which is useful if you are working with simple content types. Of course you can always define your own edit template and use that instead.
What a nice view
Of course, all of those templates and content types are for naught if you don’t have a way to actually show the content to users. This is where the new Dynamic Content Viewer comes in. Just add the viewer module to a page and you are quickly on your way. You will immediately see a difference from past DNN behavior. When you add the viewer module, it will immediately show you a new quick settings display in the module action menu.
NOTE: In the final release we’ll also be minimizing the module section of the control panel once you add a module to the page.
Quick settings is a new feature in DNN 8 that can be used by any module developer to give editors quick access to module specific settings. There is no need to open a new dialog box or to even do a page refresh when you are done. It also eliminates a lot of the extra settings which are available in the module settings dialog box. This lets you quickly change module settings and get back to the real work of editing or displaying your content.
Quick settings can be created in web forms, MVC or SPA module types and is based on defining a module control using a “QuickSettings” control key. Your “view” (html, ascx or cshtml) just needs to include some JavaScript that wires up the save buttons onSave event which will call your JavaScript method when the save button is called. You can also add an option for the onCancel event as well. It is up to your module to make the appropriate AJAX calls to save the data and to refresh your main view as appropriate.
NOTE: There is a bug in the Dynamic Content Viewer in CTP 5 and you will need to do a page refresh after saving the Quick Settings in order to get the Edit Content menu to show you the edit option.
Once configured the Viewer will show you your content using the selected template. To edit your content, just use the Module Action Menu and select Edit Content. This will show a modal dialog using the Edit Template configured in the quick settings. If you have selected the HTML or Markdown content types and the Auto Generated edit template then you should get a rich editor that looks something like the one shown here.
But Wait There’s More
This covers the basics of using the new Dynamic Content Creator in CTP 5. This is just one of the features available in this release. We also have added some new manifest extensions that allow module developers to automatically create an admin or host page for their module during install. We’ll do a separate blog once that feature is a little more locked down as we expect it to change before the beta release next month.
We still have a number of significant enhancements and bug fixes coming before the final DNN 8 release. I urge you to take a look at CTP 5 and tell us what you like and what you don’t like. Now is the time to register your feedback while there is still time to change things if needed. As we get closer and closer to release, we’ll be adding more documentation on all the awesome new features we have included in DNN 8. Don’t forget, with the new incremental upgrade feature, if you install CTP 5, you’ll be able to upgrade directly to later preview releases or to the final DNN 8 release when it becomes available.