Bonsoir
J'essaye de classer des images par album mais cela ne fonctionne pas, lors du foreach des images, voici le code :
<div class="albums index">
<h2><?php echo __('Albums');?></h2>
<table cellpadding="0" cellspacing="0">
<?php debug($albums) ;?>
<?php foreach ($albums as $album): ?>
<tr>
<td><?php echo $album'Album']'id']; ?> </td>
<td><?php echo $album'Album']'title']; ?> </td>
<?php foreach ($albums as $album): ?>
<td><?php echo $album'Galery']'id']; ?> </td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
Le debug de $albums donne ceci :
app\View\Albums\index.ctp (line 5)
Array
(
[0] => Array
(
[Album] => Array
(
[id] => 1
[title] => Album1
)
[Galery] => Array
(
[0] => Array
(
[id] => 1
[title] => Test
[image] => 1
[date] => 2011-10-21 19:37:00
[album_id] => 1
)
[1] => Array
(
[id] => 2
[title] => Test2
[image] => 2
[date] => 2011-10-21 19:47:00
[album_id] => 1
)
)
)
[1] => Array
(
[Album] => Array
(
[id] => 2
[title] => Album2
)
[Galery] => Array
(
[0] => Array
(
[id] => 3
[title] => Test3
[image] => 3
[date] => 2011-10-21 19:50:00
[album_id] => 2
)
[1] => Array
(
[id] => 4
[title] => Test4
[image] => 4
[date] => 2011-10-21 19:51:00
[album_id] => 2
)
[2] => Array
(
[id] => 5
[title] => Test5
[image] => 5
[date] => 2011-10-21 19:51:00
[album_id] => 2
)
)
)
L'erreur...
1 Album1
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
2 Album2
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
3 Album3
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
4 Album4
Notice (8): Undefined index: id [APP\View\Albums\index.ctp, line 14]
Flo2315