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.

Widgets /

Discuss SilverStripe Widgets.

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

Customising RandomContent widget - show first paragraph only


Go to End
Reply


1227 Views

Avatar
greenpea

Community Member, 19 Posts

24 June 2012 at 7:12pm

Hi, I made an change to the RandomContent widget so that it would show only the first paragraph of a page.

The original code

<div class="RandomContentWidget">
	<% control RandomContent %>
		$Content
	<% end_control %>
</div>

Updated to show only the first paragraph of each page

<div class="RandomContentWidget">
	<% control RandomContent %>
	<p>$Content.FirstParagraph <a href="$Link" title="Read more on &quot;{$Title}&quot;">Read more &gt;&gt;</a></p>
	<% end_control %>
</div>

Is there a better way to do this (i.e. without using <p> tags)?