Hello,
I’m working on a home page and want to get actualities from an other page’s subpage.
It works just fine if I put the logic in the template like this :
templates/home.php :
<?php
$today = date('Ymd');
$actualites = $site->page('actualites')->children();
foreach($actualites as $actuality) {
if($actuality->date('Ymd') < $today) {
$pasts[] = $actuality;
}
if($actuality->date('Ymd') >= $today && $actuality->date('Ymd') <= $today + 7) {
$presents[] = $actuality;
}
if($actuality->date('Ymd') > $today + 7) {
$futures[] = $actuality;
}
}
?>
But it does nothing if I put it inside the controller like this :
controllers/home.php :
<?php
return function($site, $pages, $page) {
$today = date('Ymd');
$actualites = $site->page('actualites')->children();
foreach($actualites as $actuality) {
if($actuality->date('Ymd') < $today) {
$pasts[] = $actuality;
}
if($actuality->date('Ymd') >= $today && $actuality->date('Ymd') <= $today + 7) {
$presents[] = $actuality;
}
if($actuality->date('Ymd') > $today + 7) {
$futures[] = $actuality;
}
}
};
Can someone tel me what am I doing wrong ?
Thanks