Add Page Programmatically with page attributes

Permalink
Using the example from the pages overview page:

$parentPage = Page::getByPath("/sample");
$data = array(
        'name' => "sample2",
        'cHandle' => "sample2handle",
    'cDescription' => "Add page test."           
);
$pt = CollectionType::getByHandle("page_type_handle");
$newPage = $parentPage->add($pt,$data);


How would one go about adding data to an attribute on the new page? Is this even possible?

 
Remo replied on at Permalink Best Answer Reply
Remo
yes, just append this

$newPage->setAttribute('handle', 'value');
lexbi replied on at Permalink Reply
Thanks will give this a go later today
extremecreations replied on at Permalink Reply
extremecreations
Yep, this works a treat.

Thanks Remo.