Check if current page is in pages field

Hi,

I have a pages field, and need to check if the currently viewed page is present in the field, and if so show links to all the pages in that field, and also style the current page link differently when displayed (it is setting up a subnav).

What is the best way of doing this? Thanks for any help

$hasCurrentPage = $page->pagelinkfield()->toPages()->has($page);
1 Like