Page Importer - Getting new page ID

Permalink
Hi,
I'm making a custom Job to import a few 100 pages from a CSV file. I have this code to make the page under /press-releases

Loader::model('collection_types');
$pr = Page::getByPath('/press-releases');
$data = array();
$data['cName'] = $data_array['fdt_title'];
$data['cDescription'] = $data_array['fdt_title'];
$data['cDatePublic'] = $data_array['fdt_date_on'];
$ct = CollectionType::getByHandle('right_sidebar');
$pr->add($ct, $data);


So far so good. Then I want to add some content to the new page I've just created, but since C5 has auto-generated the handle (so I don't know it), and I don't know the new pageID, I don't know how to get the new page object to then add content:

$bt = BlockType::getByHandle('content');
$data = array();
$data['uID'] = '1';
$data['content'] = t('Some Content');
$myNewPage->addBlock($bt, "Main", $data);


I'm sure I'm missing something obvious here. Any help would really be appreciated.

moth
 
moth replied on at Permalink Reply
moth
Anyone? My questions always plummet!
okhayat replied on at Permalink Reply
okhayat
The line
$pr->add($ct, $data);
returns a Page pointer. Just assign it to a variable, like
$newPage = $pr->add($ct, $data);
and you have it.
Then, directly add the block to it in the loop.
moth replied on at Permalink Reply
moth
Ah.. Thank you!