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.

Template Questions

How to use DataObjectSet->GroupedBy() ?


Reply

4 Posts   2172 Views

Avatar
brokemeister

30 July 2009 at 2:05am (Last edited: 30 July 2009 2:07am), Community Member, 30 Posts

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

30 July 2009 at 9:18am Forum Moderator, 5511 Posts

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

17 November 2009 at 3:37am Community Member, 2 Posts

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

17 November 2009 at 3:45am Community Member, 30 Posts

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