Created
January 20, 2011 22:44
-
-
Save gabesumner/788850 to your computer and use it in GitHub Desktop.
This is the code I used to restyle the blog posts in the Education Starter Kit that is found in the Sitefinity SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Control Language="C#" %> | |
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %> | |
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %> | |
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %> | |
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> | |
<%@ Import Namespace="Telerik.Sitefinity" %> | |
<%@ Register TagPrefix="cc1" Namespace="SitefinityWebApp.Tools" Assembly="SitefinityWebApp" %> | |
<telerik:RadListView ID="Repeater" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false"> | |
<LayoutTemplate> | |
<ul class="sfpostsList"> | |
<asp:PlaceHolder ID="ItemsContainer" runat="server" /> | |
</ul> | |
</LayoutTemplate> | |
<ItemTemplate> | |
<li class="sfpostListItem"> | |
<h2 class="sfpostTitle"> | |
<sf:DetailsViewHyperLink TextDataField="Title" ToolTipDataField="Description" runat="server" /> | |
</h2> | |
<p class="sfgenericAuthorAndDate"> | |
<asp:Literal ID="Literal2" Text="<%$ Resources:Labels, By %>" runat="server" /> | |
<sf:PersonProfileView runat="server" /> | |
<sf:FieldListView ID="PostDate" runat="server" | |
Format=" | {PublicationDate.ToLocal():dd MMM, yyyy}" | |
/> | |
</p> | |
<div class="sfPostContent"> | |
<cc1:Truncate Text='<%# Eval("Content")%>' WordLength="100" runat="server" /> | |
</div> | |
<div class="sfPostLink"> | |
<sf:DetailsViewHyperLink Text="Read More" ToolTipDataField="Description" runat="server" /> | |
</div> | |
</li> | |
</ItemTemplate> | |
</telerik:RadListView> | |
<sf:Pager id="pager" runat="server" NavigationMode="Links"></sf:Pager> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul.sfpostsList | |
{ | |
padding: 0; | |
margin: 0; | |
list-style: none; | |
} | |
li.sfpostListItem h2.sfpostTitle | |
{ | |
padding-bottom: 0; | |
margin-bottom: 0; | |
border-bottom: none; | |
font-size: 1.8em; | |
} | |
li.sfpostListItem h2.sfpostTitle a | |
{ | |
text-decoration: none; | |
} | |
li.sfpostListItem .sfPostContent h2 | |
{ | |
border-bottom: none; | |
} | |
li.sfpostListItem .sfgenericAuthorAndDate | |
{ | |
padding: 0; | |
margin: 0; | |
} | |
li.sfpostListItem .sfPostLink | |
{ | |
padding: 7px; | |
border-bottom: 1px solid #444; | |
background-color: #f3f3f3; | |
margin-bottom: 1.5em; | |
font-weight: bold; | |
font-size: 1.0em; | |
} | |
li.sfpostListItem .sfPostLink a | |
{ | |
text-decoration: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.UI.WebControls; | |
using Telerik.Sitefinity.Data.Summary; | |
namespace SitefinityWebApp.Tools | |
{ | |
public class Truncate : Literal | |
{ | |
/// <summary> | |
/// Determines how many words the Text will be truncated to. Sitefinity will preserve the HTML. | |
/// </summary> | |
public int WordLength | |
{ | |
get | |
{ | |
return _wordlength; | |
} | |
set | |
{ | |
_wordlength = value; | |
} | |
} | |
/// <summary> | |
/// This is used for backwards compatibility. The first version of Truncate only had the Length property. | |
/// </summary> | |
public int Length | |
{ | |
get | |
{ | |
return WordLength; | |
} | |
set | |
{ | |
WordLength = value; | |
} | |
} | |
protected override void CreateChildControls() | |
{ | |
var settings = new SummarySettings(SummaryMode.Words, WordLength, false); | |
Text = SummaryParser.GetSummary(Text, settings); | |
base.CreateChildControls(); | |
} | |
private int _wordlength = 20; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment