Feature #7389

GroupedForViewHelper group by object

Added by Lienhart Woitok almost 12 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Should have
Category:
ViewHelpers
Target version:
-
Start date:
2010-04-20
Due date:
% Done:

100%

Estimated time:
Has patch:

Description

Currently it is not possible to group by an object.

Example :

class Foo {
    /** @return array<Bar> */
    public function getBars();
}

class Bar {
    /** @return Baz */
    public function getBaz();
}

class Baz {
}

Now, lets loop over them using the Baz objects as key.

<f:groupedFor each="{foo.bars}" as="bars" groupBy="baz" groupKey="baz">
    {baz.title}:
    <ul>
        <f:for each="{bars}" as="bar">
            <li>{bar.name}</li>
        </f:for>
    </ul>
</f:groupedFor>

I expected output from this loop, something like

    A crazy baz title:
    <ul>
            <li>A named bar</li>
            <li>Another named bar</li>
    </ul>
    Second crazy baz title:
    <ul>
            <li>A further named bar</li>
            <li>And yet another named bar</li>
            <li>The last named bar</li>
    </ul>

I got nothing. So I dug into this and created the attached patch, enabling the expected behavior.


Files

fluid-GroupedForViewHelper-objectAsKey.diff (1.48 KB) fluid-GroupedForViewHelper-objectAsKey.diff Lienhart Woitok, 2010-04-20 16:02
7389_v2_FLOW3.patch (6.51 KB) 7389_v2_FLOW3.patch 2nd version of this patch (FLOW3 package) Bastian Waidelich, 2010-05-17 11:39
7389_v2_typo3v4.patch (6.5 KB) 7389_v2_typo3v4.patch 2nd version of this patch (extension) Bastian Waidelich, 2010-05-17 11:39
#1

Updated by Bastian Waidelich over 11 years ago

  • Project changed from 534 to TYPO3.Fluid
#2

Updated by Bastian Waidelich over 11 years ago

  • Category set to ViewHelpers
  • Status changed from New to Accepted
  • Assignee set to Bastian Waidelich
  • Priority changed from Could have to Should have
  • Branch set to v4 + v5

Note: I just moved this issue from "Extbase MVC Framework" to "Fluid" - the patch is created against the v4 extension. I'll take care of this

#3

Updated by Bastian Waidelich over 11 years ago

Can someone please double check the attached patches so they can be committed

#4

Updated by Bastian Waidelich over 11 years ago

  • Status changed from Needs Feedback to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4620.

Also available in: Atom PDF