Get the 'nht' child of a page query

Hello,

I’m new to the forum but not new to Kirby’s power.
However, I’m struggeling with the following:

<?= $site->find('Full-Catalogue')->selectsource()->nth(2)->toPage()->title() ?>

How can I manage to grab a ‘nth-child’ from a query of pages? In this example ‘selectsource’ is a query of pages.

Context: I’m making website for a semi-online group-exhibition on which the visitor can download an on-demand catalogue. They can collect pages throughout the website and save it’s coresponding page-number to the local-storage. When they’ve collected the pages they like they are able to combine the pages to a personal catalogue-pdf. Everything is working except this line of php…

What is a query of pages. Selectsource seems to be a field? A pages field? Or a custom method?

Also, page slugs are always lowercase, so it should probably be find(‘full-catalogue’)?

Oh, yess sorry. It’s indeed a pages field :slight_smile:
I’ve changed it to lowercase, with little effect…

I found the sollution! I discovered that the ‘nth’ function only works with collections.

The collection code (site/collections/catalogue.php):

return function ($site) {
return $site
    ->find('full-catalogue')
    ->selectsource()
    ->toPages();

In the template:
<?= $kirby->collection("catalogue")->nth(2)->title() ?>