How do I limit the summary in the blog module?
Hi there,
I am using the blog list widget to show a list of blog posts on my home page. However, Im struggling to get the list of posts to display summaries of the posts. Here is my custom template code:
01.
<%@ Control Language="C#" %>
02.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
03.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
04.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
05.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
06.
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
07.
<%@ Import Namespace="Telerik.Sitefinity" %>
08.
09.
<
telerik:RadListView
ID
=
"Repeater"
ItemPlaceholderID
=
"ItemsContainer"
runat
=
"server"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
10.
<
LayoutTemplate
>
11.
<
sf:ContentBrowseAndEditToolbar
ID
=
"MainBrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Add"
></
sf:ContentBrowseAndEditToolbar
>
12.
<
ul
class
=
"sfpostsList sfpostListTitleDateSummary"
>
13.
<
asp:PlaceHolder
ID
=
"ItemsContainer"
runat
=
"server"
/>
14.
</
ul
>
15.
</
LayoutTemplate
>
16.
<
ItemTemplate
>
17.
<
li
class
=
"sfpostListItem"
>
18.
19.
<
div
class
=
"sfpostDate"
>
20.
<
sf:FieldListView
ID
=
"PostDate"
runat
=
"server"
Format
=
"PublicationDate.ToLocal():MMM dd, yyyy"
/>
21.
</
div
>
22.
<
div
class
=
"blogSummary"
>
23.
<
sitefinity:HtmlField
runat
=
"server"
DisplayMode
=
"Read"
Value='<%# Eval("Content")%>' />
24.
</
div
>
25.
26.
<
sf:FieldListView
ID
=
"PostContent"
runat
=
"server"
Text
=
"0"
Properties
=
"Summary"
WrapperTagName
=
"div"
WrapperTagCssClass
=
"sfpostSummary"
/>
27.
28.
<
sf:DetailsViewHyperLink
ID
=
"FullStory"
Text
=
"Read More"
runat
=
"server"
CssClass
=
"sfpostFullStory"
/>
29.
<
sf:ContentBrowseAndEditToolbar
ID
=
"BrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Edit,Delete,Unpublish"
></
sf:ContentBrowseAndEditToolbar
>
30.
</
li
>
31.
</
ItemTemplate
>
32.
</
telerik:RadListView
>
33.
<
sf:Pager
id
=
"pager"
runat
=
"server"
></
sf:Pager
>
34.
<
asp:PlaceHolder
ID
=
"socialOptionsContainer"
runat
=
"server"
/>
Hey Peter,
Officially you can go to your blogposts overview screen in the backend ( content > blogs > click on the blog) and then on the righthand side click on "Custom fields for posts", there you can alter the limitation settings for the length of the blog summary (Change Max -1 characters to 50).
<
sitefinity:TextField
ID
=
"FieldListView1"
runat
=
"server"
DisplayMode
=
"Read"
WrapperTagCssClass
=
"sfpostSummary"
Value='<%# (Eval("Summary")).ToString().Substring(0, 50)%>'
/>
Value='<%# CapLength("Summary", 50)%>'
protected
string
CapLength(
string
fieldName,
int
maxLength)
object
value =
this
.Eval(fieldName);
if
(value ==
null
)
return
null
;
string
fieldContent = value.ToString();
if
(fieldContent.Length > maxLength)
return
fieldContent.Substring(0, maxLength);
else
return
fieldContent;