Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » How to use DataObjectSet->GroupedBy() ?

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

Page: 1
Go to End
Author Topic: 2165 Views
  • brokemeister
    Avatar
    Community Member
    30 Posts

    How to use DataObjectSet->GroupedBy() ? Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: How to use DataObjectSet->GroupedBy() ? Link to this post

    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;
    }

  • kimmings
    Avatar
    Community Member
    2 Posts

    Re: How to use DataObjectSet->GroupedBy() ? Link to this post

    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

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: How to use DataObjectSet->GroupedBy() ? Link to this post

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

    2165 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.