Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

LatestNews vs. Article Holder

Go to End

3 Posts   2578 Views


Community Member, 2 Posts

22 July 2008 at 5:12am

Is there anyway to limit the amount of characters returned for the $Content?

I like how the News displays on the article holder page, but for sidebar (latest news) on the homepage, I dont want to display so much. Maybe 120 characters max.

Is this possible?


function LatestNewsItems($num = 3) 
	$news = DataObject::get_one("ArticleHolder");
	return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;

<% control LatestNewsItems %>
<% if FirstLast != last %><div class="hr">&nbsp;</div><% end_if %>
<% end_control %>


126 Posts

22 July 2008 at 11:48am

Edited: 22/07/2008 11:49am


try this page:

That's probably what you are looking for. You can limit the number of characters, or the number of words, display the first paragraph only, etc...

Just add e.g.


You can also change the default characters that are displayed at the end if the text exceeds the maximum length (default is '...'). See here:


BLU42 Media

Community Member, 71 Posts

22 July 2008 at 11:50am

You sure can... easily too! There are some cool functions built right into the framework that you can use in your ss template. Just switch out $Content with one of these:


Check out for more details.

Hope that helps!