Fork me on GitHub
2sxc 8.11 for DNN 7 to 9
Website Builder, Content Manager, App-System: free and amazing - done your way

Separate Presentation-Settings from Real Content

Introduced in Version 03.00.00

Understanding the Need

Many scenarios require output-configuration. Here a few examples:

  1. You have a template that shows simple content, and sometimes the title should be <h1>, sometimes <h2>, etc. Instead of creating 6 different templates, it would be easier to allow simple configuration of the heading-tag. This kind of presentation-configuration is handled by the Presentation-entity. 
  2. Your Title/Text/Image allows the user to place the image no the right or on the left side. Instead of creating multiple templates, let's just let the user configure the variation he wants. This too is handled by the Presentation-entity. 
  3. A complex template like a Google-map can configure 10-20 different parameters. These should not be set in the address which we will show - because these parameters have nothing to do with the address itself. So we need a way to provide 10-20 input-fields, drop-downs etc. - but not mix it with the address itself. These 10-20 input fields would be handled in a Presentation-entity. 
  4. The same piece of information - like the address of 2sic - could be shown on different pages. Each instance might have some presentation configuration that differs from the other ones. It would be impossible to configure this if the config-fields were in the address-entity. So we place them in a separate Presentation-entity. 

Important: Presentations are 90% Stable, so use Defaults whenever possible 

One thing we discovered, is that configurable templates can be annoying because often there is a default configuration which applies to 90%. For example, if you create a configurable heading-tag <h1> through <h6>, usually 90% of the cases need <h1> because this is used on every page. Such defaults are handled easily by providing the template with a default-presentation entity containing these common settings. These will automatically be used if not overruled. 

So how does this work? Each template has data to show (the Content-entity), but it can optionally also have a presentation-data (the Presentation-entity). 

Example: Using the Presentation to control the heading-tag in a template

These are the content types

  1. Simple Content - with the following fields
    1. Title (text, 1 line)
    2. Content (wysiwyg-text)
    3. Image (link to an image file)
  2. Presentation for Simple Content with the following field
    1. Heading (text, drop-down containing h1, h2, h3, h4, h5, h6)

The template configuration specifies the simple-content as the content type, and the presentation-for-simple-content as the Presentation-type. The user now has an additional section in the Edit-UI to configure the presentation. 

The template would then contain the following fragment:

  • Token: Instead of the classic <h1>[Content:Title]</h1>, it would have <[Presentation:Heading]>[Content.Title]</[Presentation:Heading]>
  • Razor: Instead of the classic <h1>@Content.Title</h1>, it would have  <@Presentation.Heading>@Content.Title</@Presentation.Heading>

Power-Feature: Using Default-Values in this Presentation

Now remember that probably 90% of all use cases for this will want an <h1> tag. It would be annoying to have to specify this every time, so please create a demo-entity and assign it in the template-configuration. 

All Features of Presentation-Types

  1. Presentation-Types are optional, templates don't require them
  2. Default-Values are optional, but highly recommended
  3. Data / Values in a presentation-content-type are not indexed by the search
  4. Presentation-Items are unique for every use. So if you show a piece of content in many places, each occurrence can have different presentation-settings
  5. Content-Items can have a presentation...
  6. ...Lists can have their own, different presentation. This is used to configure the list (for example, how many items to show before paging)
  7. ...and Lists can also have their own default presentations for fallback
  8. The UI always allows the editor to revert back to the default-settings

Tags for this feature

2serve . 2invent . 2create is 2be.