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.

Template Questions /

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

How to use DataObjectSet->GroupedBy() ?


Go to End


4 Posts   2976 Views

Avatar
brokemeister

Community Member, 30 Posts

30 July 2009 at 2:05am

Edited: 30/07/2009 2:07am

Hi!
How does the GroupedBy work?
Items returns a DataObjectSet...

I just have these lines, which do not work... :(

<% control Items.GroupedBy(Title) %>
	<% control Children %>
		<div class="item $ClassName">
			
				<h3>$Title</h3>
			
			<h4>$Role<br />$FirstName $LastName</h4>
			<p>$Phone<br />$Fax<br />Email</p>
		</div>
	<% end_control %>
<% end_control %>

Any ideas?

Thanks
Malte

Avatar
Willr

Forum Moderator, 5523 Posts

30 July 2009 at 9:18am

Hmm can't say I have ever tried to use GroupedBy in a template file. If that doesn't work you might want to try:

function GroupedSomething() {
 $children = $this->Children();
 if($children) $children->groupBy('Title');
 return $children;
}

Avatar
kimmings

Community Member, 2 Posts

17 November 2009 at 3:37am

I have a similar issue.
When I use $dataSet->groupBy('column-name') I get a blank page.
When I remove the groupBy method the page displays :(

Avatar
brokemeister

Community Member, 30 Posts

17 November 2009 at 3:45am

A while a go I got it working, but if I remember it corretly. It was only working with pages.