Content Presentation Settings
When Data is used as Content it can also have Presentation settings. This is important because the same piece of content (like an Address) may need to be visualized different ways depending on how it's used.
Let's say we have an Address of 2sic in Switzerland as Data, and we're using it in a few places:
- In the footer of the website we're just showing it, the template says how it's shown
- In the We make Websites Page we have a CTA (Call to Action) with two addresses, and the 2sic address is configured to be highlighted using the Presentation
- We have a Contact Page where it's shown in a Google-Maps - there we configured the Presentation to use a pink pin
Since the Presentation is directly connected to the Item it's showing, the Edit-UI will open both items for editing together:
More Use-Case Examples
- You have a template that shows simple content, and sometimes the title should be
<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.
- 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.
- 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.
- 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.
Demo / Defaults Behavior
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
<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.
Presentation Settings are not changed in 90% of all cases, so use Defaults whenever possible!
Very often the Presentation contains default settings which are often left untouched. In these cases the Presentation-item is not stored, but the Demo-data is provided automatically. This allows you to update the defaults an any time and it will be reflected on all items which have unmodified Presentation settings.
Here's what Presentation looks like when inheriting defaults:
This is what Presentation looks like when you set it on the current item:
Available on each Content-Item and on Header
Presentation is available on each Content item and also in the Header (if a View is configured to have a List). Each Content item will have it's own presentation settings.
The View configuration determines if there is a Presentation setting on Content (or Header) and what Content-Type is to be used.
Use in Code
In C# you will usually do things like
@Content.Presentation.Color or similar. Check the C# API Docs for this.
In Tokens you will usually do things like
[Content:Presentation:Color]. Check the Tokens docs.
Example: Using the Presentation to control the heading-tag in a template
- Simple Content - with the following fields
Title(text, 1 line)
Image(link to an image file)
- Presentation for Simple Content with the following field
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.
This The template would then contain the following fragment:
Instead of the classic
it would have
Instead of the classic
...it would have
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.
Features and Behavior of Presentation-Data
- Presentation-Types are optional, templates don't require them
- Default-Values are optional, but highly recommended
- Data / Values in a presentation-content-type are not indexed by the search
- 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
- Content-Items can have a presentation...
- ...List Headers can have their own, different presentation. This is used to configure the list (for example, how many items to show before paging)
- ...and List Headers can also have their own default presentations for fallback
- The UI always allows the editor to revert back to the default-settings
- Introduced in 2sxc v3.0