I’m trying to use routing in order to route my home page to whatever page is in position 1 and I can’t figure out how to do that.
So for example, let’s say I have a unique page for each year so I have pages for 2018, 2017, 2016, etc. Each is in its corresponding position 2018=1, 2017=2, 2016=3 so that they appear in order in the navigation menu.
I want my home page to be whatever is in position 1. This year I want the home page to be the 2018 page. But when a new page is created for 2019, I want 2019 to be the home page.
What I have at the moment is the following code. It works, but obviously, I’ve hard coded that the home page should redirect to /2018
which isn’t ideal because when a new page for 2019 is created, the code will also manually have to be updated.
c:set('routes', array(
array(
'pattern' => '/'
'action' => function() {
return go('/2018');
}
)
));
How might I achieve what I’m looking to do?