Related pages / content

Hi there, I’ve looked everywhere for what I suppose is simple to achieve, but I just cant find an answer / wrap my head around the problem.

I have a a pages section called ‘projects’, each project has a related client (this is a page field) and each client has a type, how do I ‘pluck’ all of the client types from all listed projects? I need this for a search filter.

e.g.

$listedChildren = $page->children()->listed();
$clients = $listedChildren->pluck('projectClient', ',', true);

gives me an array of client uuids, but I don’t know how to create a collection of pages from this array, I need a collection of pages so I can then ‘pluck’ an array of clientTypes. There is probably a much cleaner way of doing this but I’m not sure how any help would be really appreciated :slight_smile:

$clients = array_map(fn($item) => page(str_replace("'", '', $item)), $listedChildren->pluck('projectClient', '-', true));

Very much appreciate your help @texnixe, this worked beautifully.

Thanks!