ContentBlock
IMPORTANT: Starting from release 8.6, the ContentBlock server control was replaced by the FrameworkUI: <ektron:ContentView> templated server control. If you are already using the ContentBlock server control, you can continue to do so, but Ektron recommends using current versions of functionality.
The ContentBlock server control displays the following types of content blocks on an Web page.
- Static. Displays one specified content block
- Dynamic. Displays the content block of the ID passed through a URL parameter
- XML. Displays the content from the XML or XHTML code
Inserting the ContentBlock server control onto a page
Prerequisite
You must have installed the server controls. See Installing server controls into Visual Studio Toolbox.
- In Visual Studio, choose View > Toolbox.
- Click the Ektron server control tab to display the server controls.
- Drag the ContentBlock server control and drop it into the desired location on the page.
NOTE: You also can place the cursor on the page where you want the server control, then double click the server control that you want.
<CMS:ContentBlock ID="ContentBlock1" runat="server" />
- Click on
ContentBlock
in the code to display and modify the control’s properties using the Properties window of Visual Studio. The page is updated as you modify the property values.
ContentBlock properties
The following are Ektron-specific server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified. properties. For information about native .NET properties such as font, height, width and border style, use Visual Studio® help.
- CacheInterval (Double)
The number of seconds that a server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified.’s data is cached. The default is 0 (zero). For example, if you want to cache the data for 5 minutes, set to 300. See also: Caching with server controls.
- DefaultContentID (Long)
The ID of a content block that appears where you insert this server control. If you don’t know the ID number of the content block, use the CMS Explorer to browse to it.See also: Browsing your Ektron site using CMS Explorer.
NOTE: If you identify a content block that displays an Office document which will be published as HTML, make sure the template sets
<span>
tags to display the content as a block. - DisplayXslt (String)
Ignore for a non-XML content block.
- DoInitFill (Boolean)
By default, Fill occurs during the Page_Init event. Set to false if you want to postpone the fill-action until later. In this case, Fill is automatically called during the Page Render event. You might do this if you need to set or change a property on the control in code-behind and have it render with your changes shown.
- DynamicParameter (String)
Select None - Use Default. This parameter is used for dynamic content blocks.
- GetAnalyticsData (Boolean)
Set this property to True if you want the following information for each content in the list. Returns Content View Count, Content Rating, Content Rating Average. Create your own XSLT styles to display this data.
IMPORTANT: This property provides reliable data only when the Business Analytics Feature is on. See Running Ektron Business Analytics.
- Hide (Boolean)
Hides or displays the output of the control in design time and run time.
- True. Hide the control output.
- False. Display the control output.
- Language (Integer)
Set a language for viewing content; shows results in design-time (in Visual Studio) and at run-time (in a browser).
- SuppressWrapperTags (Boolean)
IMPORTANT: If you want to let content authors edit this content using Ektron’s Edit in Context feature, this must be set to false.
Suppresses the output of the span/div tags around the control.
- True. Suppress wrap tags.
- False (default). Allow wrap tags.
- WrapTag (String)
Lets a developer specify a server control’s tag.
- Span (default). Designate an inline portion of an HTML document as a span element.
- Div. Apply attributes to a block of code.
- Custom. Lets you use a custom tag.
Using a dynamic content block
Use a dynamic content block to display a content block whose ID is passed through a URL parameter. You would use this server control with a dynamic template.
The following example uses the ContentBlock server control to pass the id as a URL parameter. When a user clicks a link that passes the content block ID as a URL parameter, that content block appears. If that content block is not available, content block 1 appears
The following are Ektron-specific server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified. properties. For information about native .NET properties such as font, height, width and border style, use Visual Studio® help.
Dynamic ContentBlock properties
- Authenticated (String)
Indicates if you are logged into the CMS Explorer and can use it to browse to content, collections, and so on. See also: Browsing your Ektron site using CMS Explorer.
- DefaultContentID (Long)
The ID of a content block that appears where you insert this server control. If you don’t know the ID number of the content block, use the CMS Explorer to browse to it.See also: Browsing your Ektron site using CMS Explorer
NOTE: If you identify a content block that displays an Office document which will be published as HTML, make sure the template sets
<span>
tags to display the content as a block. - DisplayXslt (String)
Ignore for a non-XML content block.
- DoInitFill (Boolean)
By default, Fill occurs during the Page_Init event. Set to false if you want to postpone the fill-action until later. In this case, Fill is automatically called during the Page Render event. You might do this if you need to set or change a property on the control in code-behind and have it render with your changes shown.
- DynamicParameter (String)
Select id. When you do, this server control uses the content block passed as a URL parameter.
- Hide (Boolean)
Hides or displays the output of the control in design time and run time.
- True. Hide the control output.
- False. Display the control output.
- Language (Integer)
Set a language for viewing content; shows results in design-time (in Visual Studio) and at run-time (in a browser).
- SuppressWrapperTags (Boolean)
Suppresses the output of the span/div tags around the control.
- True. Suppress wrap tags.
- False (default). Allow wrap tags.
IMPORTANT: If you want to let content authors edit this content using Ektron’s Edit in Context feature, this must be set to false.
- WrapTag (String)
Lets a developer specify a server control’s tag.
- Span (default). Designate an inline portion of an HTML document as a span element.
- Div. Apply attributes to a block of code.
- Custom. Lets you use a custom tag.
XML ContentBlock properties
Use an XML content block to display an XML content block on an Ektron Web page.
The following are Ektron-specific server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified. properties. For information about native .NET properties such as font, height, width and border style, use Visual Studio® help.
- Authenticated (String)
Indicates if you are logged into the CMS Explorer and can use it to browse to content, collections, and so on. See also: Browsing your Ektron site using CMS Explorer.
- CacheInterval (Double)
The number of seconds that a server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified.’s data is cached. The default is 0 (zero). For example, if you want to cache the data for 5 minutes, set to 300. See also: Caching with server controls.
- DefaultContentID (Long)
The ID of a content block that appears where you inserted this server control if no other content block is identified, or is not available. If you don’t know the ID number of the content block, use the CMS Explorer to browse to it.See also: Browsing your Ektron site using CMS Explorer.
- DisplayXslt (String)
If desired, enter a relative or absolute path to an Xslt that determines the display of the page. If you do not define the
DisplayXslt
property, theOverrideXslt
property specifies an XSLT identified in the Edit Smart Form Configuration screen. See also: Working with Smart Forms, and the Ektron KnowledgeBase article "HOW TO:Add acceptable XSLT files to the system".WARNING! Files stored in the
siteroot\Workarea
folder are overwritten (or deleted) when you upgrade Ektron. To avoid problems, copy the default file to a folder outside thesiteroot\workarea
folder then edit it. If there is no default file, create the file outside thesiteroot\workarea
folder. Next, in this property, enter the path to that file relative to the site root folder. - DoInitFill (Boolean)
By default, Fill occurs during the Page_Init event. Set to false if you want to postpone the fill-action until later. In this case, Fill is automatically called during the Page Render event. You might do this if you need to set or change a property on the control in code-behind and have it render with your changes shown.
- DynamicParameter (String)
To make this content block dynamic, select id. When you do, this server control uses the content block passed as a URL parameter.
- Hide (Boolean)
Hides or displays the output of the control in design time and run time.
- True. Hide the control output.
- False. Display the control output.
- Language (Integer)
Set a language for viewing content; shows results in design-time (in Visual Studio) and at run-time (in a browser).
- SuppressWrapperTags (Boolean)
Suppresses the output of the span/div tags around the control.
- True. Suppress wrap tags.
- False (default). Allow wrap tags.
- WrapTag (String)
Lets a developer specify a server control’s tag.
- Span (default). Designate an inline portion of an HTML document as a span element.
- Div. Apply attributes to a block of code.
- Custom. Lets you use a custom tag.
Retrieving the XML structure of an XML ContentBlock
Retrieving the XML structure of XML content allows for greater control over developing XSLs. The following example shows how to retrieve the XML structure.
- Open a new Web form.
- Drag and drop a Content Block server control onto it.
- Set the DefaultContentID to an XML content block.
IMPORTANT: This does not work with HTML content blocks, as there is no XML structure to output.
- Drag and drop a textbox on the Web form.
- Set the
TextMode
property to MultiLine. - It is also recommended that you set the width of the text box to at least 400 px.
NOTE: On the code-behind page, add the following line.
TextBox1.Text = ContentBlock1.EkItem.Html - Build the project.
- View the form in a browser. The XML structure of the content block appears in the text box.
Using ContentBlock programmatically
The following code displays a content block:
NOTE: Before adding these lines of code, drag and drop a literal box on your Web form.
Dim MyContentBlock As New ContentBlock MyContentBlock.DefaultContentID = 8 MyContentBlock.Page = Page MyContentBlock.Fill() Literal1.Text = MyContentBlock.EkItem.Html
To display a content block with the content block title:
NOTE: Before adding these lines of code, drag and drop a 2 literal boxes on your Web form.
Dim MyContentBlock As New ContentBlock MyContentBlock.DefaultContentID = 8 MyContentBlock.Page = Page MyContentBlock.Fill() Literal1.Text = MyContentBlock.EkItem.Title Literal2.Text = MyContentBlock.EkItem.Html