Introduction
The ContentHelper class contains helper methods for all content. This includes methods for getting the url of a content, check if a content is selected in the public web site navigation hierarchy and so on. Please check out the table below for all methods available in the ContentHelper class.
Gets the thumbnail url for the specified file.
Methods
| Method | Description |
| ThumbUrl | Gets the thumbnail url for the specified file. |
| IsSelected | Verifies if a specific content is an ancestor of the selected content. This method extends the Content class |
| MenuTitle | Gets the string that should be used in menus. This method extends the Content class |
| Url | Resolves an url of the selected content. This method extends the Content class |
| TopContent | Gets the top most content relative to current content. This method extends the Content class |
Examples
Example 1. Get the full path url of the content with id 25
Model.Content content = ContentService.Get<Model.Content>(25);
string url = content.Url(true);
Example 2. Get the menu title for a Content item. This example shows how a top navigation could be built.
<ul id="topnavigation"">
<asp:Repeater id="navigation" runat="server">
<ItemTemplate>
<li><a href=""><%# ((Model.Content)Container.DataItem).MenuTitle %></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
Example 3. Get the top most content relative to the current content. As an example, you could use this to render a sub navigation.
Model.Content topcontent = Content.TopContent();
//Use the topcontent to render a sub navigation.
BuildNavigation(topcontent);
Example 4. Create a thumbnail from an image with a width of 100px
BinaryContent file = ContentService.Get<BinaryContent>(123);
string thumburl = file.ThumbUrl(100, 0);