グループ化して年ごとにリストしたい賞のリストがあります。アイテムをリストすることはできますが、ネストに失敗しました。
/////配列
Array
(
[0] => Array
(
[Award] => Array
(
[id] => 5
[order] => 4
[publish] => 1
[year] => 2015
[title] => Test Award #5
[copy] => Duis aute irure dolor in reprehenderit.
[slug] => test-award-5
)
)
[1] => Array
(
[Award] => Array
(
[id] => 4
[order] => 3
[publish] => 1
[year] => 2014
[title] => Test Award #4
[copy] => Duis aute irure dolor in reprehenderit.
[slug] => test-award-4
)
)
[2] => Array
(
[Award] => Array
(
[id] => 1
[order] => 0
[publish] => 1
[year] => 2013
[title] => Test Award #1
[copy] => Duis aute irure dolor in reprehenderit.
[slug] => test-award-1
)
)
[3] => Array
(
[Award] => Array
(
[id] => 2
[order] => 1
[publish] => 1
[year] => 2013
[title] => Test Award #2
[copy] => Duis aute irure dolor in reprehenderit.
[slug] => test-award-2
)
)
)
////コントローラ
class AwardsRecognitionController extends AppController {
var $name = 'Award';
/*****
PUBLIC
*****/
function index(){
$awards=$this->Award->find('all', array(
'conditions'=>array('publish'=>1),
'order'=>array('Award.year DESC')
));
$this->set('awards', $awards);
}
////見る
<div id="award_container">
<?php
echo "<ul>";
foreach($awards as $award){
echo "
<li class='award' style='color:black;'>
<strong>".$award['Award']['year']."</strong>
<span class='award_title'>".$award['Award']['title']."</span>
<p>".$award['Award']['copy']."</p>
</li>
";
}
?>
</div>
私がやろうとしているのは、このようなネストされたリストにデータを出力することです。
2015
Test Award #5
2014
Test Award #4
2013
Test Award #2
Test Award #1
どんな助けでも大歓迎です!ありがとう!