Hey guys,
I have the following model-relationship:
Event <---HABTM----> Artist <-------HABTM------> Genre
Now, in my events.index view I'd like to list all events, each with
its artists, each with its genres. With pagination my index controller
function looks as follows:
$this->Event->recursive = 2;
$this->Event->order = 'Event.date, Event.start';
$this->paginate = array('limit'=>25);
$this->set('events', $this->paginate(array('Event.public'=>'1',
'Event.date>=NOW()')));
In my index View I loop through $events, then do an addional loop for
all artists of the event:
foreach ($event['Artist'] as $artist) {
echo $artist['name'];
/// <------------------------------print genres here
}
This all works fine, except for the part where I want to print the
genres for each artist. I tried the following (in the loop above):
foreach (($artist['Genre']) as $genre) {
echo $genre['name'];
}
This works fine for the first event. However, for the second event in
the list, the genres are printed twice (e.g. "Rock - Rock"), in the
third event they are ouput 3 times ("Rock - Rock - Rock"), and so
on....
What am I missing here?
Regards,
Sebastian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---