Is there a way to get one entry from a structured content without running though all entries?
e.g. i have 7 entries in my structure and i just want to echo the 6th entry’s content.
Is there a way to get one entry from a structured content without running though all entries?
e.g. i have 7 entries in my structure and i just want to echo the 6th entry’s content.
There’s the nth()
function: https://getkirby.com/docs/toolkit/api/collection/nth
So you can simply do something like that:
<?= $page->structurefield()->toStructure()->nth(6)->name() ?>
great,i have known about the nth() function, but i didn’t think it’ll work with toStructure as well, fantastic, works like a charm