ContentView
<ektron:ContentView>
and
<ektron:ContentModelSource>
The Content templated server control displays a single piece or multiple pieces of content retrieved from the Ektron CMS.
The ContentView templated server control is actually 2 controls that work together:
ContentModelSource
. Specifies the content you want to retrieve. You can use filters (CollectionFilters, ContentFilters, MetadataFilters, and TaxonomyFilters) to display a subset of the content you retrieve.ContentView
. Specifies how you want to display the content.
The ContentView templated server control has 2 templates for rendering:
Ektron_Default_Template
. Displays a single piece of content. If the ContentModelSource returns more than 1 piece of content, the first piece in the list is rendered.Ektron_ContentList_Template
. Displays a list of content items. You also can create your own ModelTemplate to customize the rendering of the content.
Attributes for Content
Properties for Content
Ektron.Cms.Framework.UI.Controls.Views.ContentView
EktronTemplateName
. Gets the default name of the template.Model
. Current Model.ModelSourceID
. Gets or sets the ID of the controller that retrieves the data.TemplateVirtualPath
. Get TemplateVirtualPath.
Ektron.Cms.Framework.UI.Controls.ContentModelSource
CollectionFilters
. CollectionFilter Controls for the ModelSource control.ContentFilters
. Content Filter Controls for the ModelSource control.MetadataFilters
. CollectionFilter Controls for the ModelSource control.ReturnMetadata
. Boolean to return metadata for the ModelSource control.TaxonomyFilters
. Taxonomy Filter Controls for the ModelSource control.
Events for Content
None.
Methods for Content
None.
Theming for Content
None.
Examples for Content
The Content templated server control has the following variations:
- CollectionFilters
- Content Item
- Content List
- Custom Item Template
- Custom List Template
- MetadataFilters
- Paging
- TaxonomyFilters
CollectionFilters example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server" OrderByField="Title" OrderByDirection="Ascending"> <Paging RecordsPerPage="3" /> <CollectionFilters> <ektron:ContentCollectionFilter Field="Title" Operator="EqualTo" Value="Our Team" /> </CollectionFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_ContentList_Template" > </ektron:ContentView>
NOTE: .aspx.cs not required.
Content Item example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server"> <ContentFilters> <ektron:ContentFilter Field="Id" Operator="EqualTo" Value="30" /> </ContentFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_Default_Template" > </ektron:ContentView>
NOTE: .aspx.cs not required.
Content List example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server"> <Paging RecordsPerPage="3" /> <ContentFilters> <ektron:ContentFilter Field="Path" Operator="StartsWith" Value="MainSite/Content/Support/Knowledge Base/" /> </ContentFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_ContentList_Template" > </ektron:ContentView>
NOTE: .aspx.cs not required.
Custom Item Template example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server"> <ContentFilters> <ektron:ContentFilter Field="Id" Operator="EqualTo" Value="30" /> </ContentFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" > <ModelTemplate> <ektron:AccessPoint ID="accessPoint" runat="server" ObjectId="<%# ContentView1.Model.ContentList.First().Id %>" DisplayType="Content" /> <div class="ektron-ui-samplecontent"> <h1><%# ContentView1.Model.ContentList.First().Title %></h1> <h4><%# ContentView1.Model.ContentList.First().EditorFirstName %> <%# ContentView1.Model.ContentList.First().EditorLastName %> </h4> <div class="ektron-ui-samplecontent-content"> <%# ContentView1.Model.ContentList.First().Html %> </div> </div> </ModelTemplate> </ektron:ContentView>
NOTE: .aspx.cs not required.
Custom List Template example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server" OrderByField="DateModified" OrderByDirection="Descending"> <ContentFilters> <ektron:ContentFilter Field="Path" Operator="StartsWith" Value="MainSite/Content/Community/"/> </ContentFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" > <ModelTemplate> <div class="ektron-ui-samplecontent"> <h3>Last <%# ContentView1.Model.ContentList.Count%> Posts </h3> <asp:ListView ID="contentList" runat="server" DataSource='<%# ContentView1.Model.ContentList %>'> <ItemTemplate> <h2><a href='<%# Eval("Quicklink") %>'><%# Eval("Title") %></a></h2> <h4>in <%# Eval("FolderName") %></h4> <%# Eval("Teaser")%> </ItemTemplate> </asp:ListView> </div> </ModelTemplate> </ektron:ContentView>
NOTE: .aspx.cs not required.
MetadataFilters example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server" OrderByField="Title" OrderByDirection="Ascending"> <Paging RecordsPerPage="3" /> <MetadataFilters> <ektron:ContentMetadataFilter TypeName="Keywords" Operator="Contains" Value="software" /> </MetadataFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_ContentList_Template" > </ektron:ContentView>
NOTE: .aspx.cs not required.
Paging example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server"> <Paging RecordsPerPage="2" /> <ContentFilters> <ektron:ContentFilter Field="Path" Operator="StartsWith" Value="MainSite/Content/Support/Knowledge Base/" /> </ContentFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_ContentList_Template" > </ektron:ContentView> <ektronUI:Pager ID="contentPager" runat="server" PageableControlID="contentModelSource" />
NOTE: .aspx.cs not required.
TaxonomyFilters example
.aspx
<ektron:ContentModelSource ID="contentModelSource" runat="server" OrderByField="DateCreated" OrderByDirection="Descending"> <Paging RecordsPerPage="3" /> <ContentFilters> <ektron:ContentFilter Field="DateCreated" Operator="GreaterThan" Value="07/17/2010" /> </ContentFilters> <TaxonomyFilters> <ektron:ContentTaxonomyFilter Field="Path" Operator="StartsWith" Value="\OnTrek Site Navigation\Company" /> </TaxonomyFilters> </ektron:ContentModelSource> <ektron:ContentView ID="ContentView1" runat="server" ModelSourceID="contentModelSource" EktronCustomTemplate="Ektron_ContentList_Template" > </ektron:ContentView>
NOTE: .aspx.cs not required.