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
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:
I'm sure I'm missing something obvious here. Any help would really be appreciated.
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.
Anyone? My questions always plummet!
The line returns a Page pointer. Just assign it to a variable, like and you have it.
Then, directly add the block to it in the loop.
$pr->add($ct, $data);
$newPage = $pr->add($ct, $data);
Then, directly add the block to it in the loop.
Ah.. Thank you!