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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

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

Customising RandomContent widget - show first paragraph only


Go to End


2491 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)?