For an editor to be able to insert text or content like images and forms we need to define one or more editable sections in the template.
The sections can be created from the UI (use Administration - Components - Templates), but here we'll focus on the most common situation - creating them from code.
Normally, a section is defined in the template's constructor:
public MyTemplate()
{
var main1 = new Dynamix.Content5.FlowLayoutTemplateComponent( "Main1" );
Components.Add( main1 );
}
The type of the added component is FlowLayoutTemplateComponent. This is the component that is most often referred to as "section" and it lets the editor insert text and content components. There are other types of TemplateComponents and it's possible to create custom template components as well.
The basic property for sections is Name. It defines a logical name for the content stored in this section. Different templates can choose to place the Main1-section at different locations or hide it (the content will still be there if the editor switches to a template where it is visible).
Text styles
Flow layouts allow the editor to format text using some or all of the text styles defined for the web site. Exactly which styles that is allowed is set by the properties DefaultTextStyle and AllowedTextStyles
main1.AllowedTextStyles.Add( NormalTextStyle.Instance );
main1.AllowedTextStyles.Add( HeadlineTextStyle.Instance );
main1.DefaultTextStyle = NormalTextStyle.Instance;
You can also add allowed text styles from the Dynamix UI.
Allowed and recommended content types
By default any content types can be inserted in any section. Sometimes it's necessary to limit the use of some content types for certain sections - maybe they will ruin the page layout or make a script stop working if they are inserted in the wrong place.
To accomplish this we begin by defining some content types as recommended for use in this section:
// Recommend "Image"
main1.RecommendedContentTypes.Add( Dynamix.Content5.ImageContentType.Instance );
// Recommend all form content types
main1.RecommendedContentTypeGroups.Add( Dynamix.ContentTypeGroup.Form );
This highlights the specified content types for the editors, but still makes it possible to insert them if they want to. We can turn this off by setting AllowRecommendedContentTypesOnly to true.
main1.AllowRecommendedContentTypesOnly = true;
Render the section in presentation pages
To render the section in a page we include the control Dynamix.Content5.Section in the markup of the template (most often an .aspx or .master-file). It is also impossible to include it in the page using code
<dx5:Section id="uiMain1" SectionName="Main1" runat="server" />