Feature #7389

GroupedForViewHelper group by object

Added by Lienhart Woitok over 5 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2010-04-20
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:ViewHelpers
Target version:-
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.

fluid-GroupedForViewHelper-objectAsKey.diff Magnifier (1.5 kB) Lienhart Woitok, 2010-04-20 16:02

7389_v2_FLOW3.patch Magnifier - 2nd version of this patch (FLOW3 package) (6.5 kB) Bastian Waidelich, 2010-05-17 11:39

7389_v2_typo3v4.patch Magnifier - 2nd version of this patch (extension) (6.5 kB) Bastian Waidelich, 2010-05-17 11:39

Associated revisions

Revision 31cc22b8
Added by Bastian Waidelich about 5 years ago

[+FEATURE] Fluid (ViewHelpers): Added URI options format, additionalParams, absolute, addQueryString & argumentsToBeExcludedFromQueryString to FormViewHelper. Resolves #8247
[+FEATURE] Fluid (ViewHelpers): GroupedForViewHelper can now group by object. Resolves #7389
[+FEATURE] Fluid (ViewHelpers): Added DebugViewHelper. Resolves #8468

History

#1 Updated by Bastian Waidelich about 5 years ago

  • Project changed from Extbase MVC Framework to TYPO3.Fluid

#2 Updated by Bastian Waidelich about 5 years ago

  • Category set to ViewHelpers
  • Status changed from New to Accepted
  • Assigned To 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 about 5 years ago

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

#4 Updated by Bastian Waidelich about 5 years ago

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

Applied in changeset r4620.

Also available in: Atom PDF