[TYPO3-mvc] How to create an archive menu of dates from my objects
Henjo Hoeksma
me at henjohoeksma.nl
Mon Jul 25 08:22:14 CEST 2011
On 2011-07-25 06:35:52 +0000, Pankaj Lele said:
> Hello Henjo,
>
>> I tried several approaches now on creating a ViewHelper, or rendering it
>> with Fluid as is, but all of them to no avail. I clearly lack some
>> understanding here and would appreciate it if some of you could point me
>> in the right direction!
>
> I think one of the idea would be to add 2 new properties year and month
> to your Item model. No need to add them to the table actually ( I have a
> little doubt if this would work but worth trying. ). Then set these 2
> properties in the __contruct() of the model.
>
> public function __contruct() {
> $this->setYear($this->getDate()->format('Y'));
> $this->setMonth($this->getDate()->format('m'));
> }
>
> Then using the f:groupedFor [1] you can easily group your objects first
> with the year and then month by nesting f:groupedFor
>
> Thanks,
> Pankaj
>
> [1]
> http://api.typo3.org/typo3v4/current/html/class_tx___fluid___view_helpers___grouped_for_view_helper.html
Hi
>
Pankaj,
thank you for your solution. I have been thinking about this, but
didn't want to clutter my model with stuff that's allready there. Since
I haven't found another way to do this, I might go for this anyaways.
Thanks again for sharing.
Henjo
More information about the TYPO3-project-typo3v4mvc
mailing list