A client likes me to add an automatic “NEW” button to the newest project in the overview of projects.
Since the projects are ordere from one up 1-project
, I thought it would be easiest to filter for the index-number 1. But I can’t find any references, what that would be in Kirby 2.
<?php if ($project->index-number() == 1): ?>
You can use $pages->indexOf($page)
, where pages would be your projects collection.
Thanks @moonwalk, that is what I thought and did with a tiny mistake.
Wrong:
<?php if ($project->indexOf($project) == 1): ?>
(resulting in every preview having a NEW! batch)
The solution is:
<?php if ($projects->indexOf($project) == 0): ?>
and that .v25 will safe my life in the future!
Thanks a lot!