How to save "exclude from nav" with php

Permalink
I have pages that are being generated via a single page administration in the dashboard.

I would like to have each page be saved as "exclude from nav" so it doesn't get added to the navigation (for this particular sort of page).

If $p is my page, can I just do:

$nav = CollectionAttributeKey::getByHandle('exclude_nav');
$nav->saveAttributeForm($p);


Or is there a step I am missing in order to add this particular attribute to the page? Or several steps?

 
12345j replied on at Permalink Reply
12345j
$p->setAttribute('exclude_from_nav',true);
hikirsch replied on at Permalink Best Answer Reply
hikirsch
so this has changed with a recent version of concrete, its not "exclude_from_nav" anymore but rather "exclude_nav"

$p->setAttribute("exclude_nav", true );