Jump to content

Importing pages with files via API


beate-neu
 Share

Recommended Posts

Hello,

I'm importing pages from the last CMS into PW. This works very well with a database dump. But I'm having problems saving

the images and downloads for each page. I copied all of the files in a folter I specified in $upload_path:

...
$page->save();
$imagegallery = explode(",", $value['filelist1']);
foreach($imagegallery as $filename) {
   //$page->imagegallery[] = $upload_path . $filename;
   //$page->imagegallery->add((string)$upload_path . $filename);
   $page->set("imagegallery", $upload_path . $filename);
}
$page->save();

none of the lines worked :( Is there a trick I don't know?

Thanks,
Beate

Link to comment
Share on other sites

$page->setOutputFormatting(false);
foreach($imagegallery as $filename) {
	$page->imagegallery->add($upload_path . $filename);
	$page->save();
}

Though I'm not sure that it's obligatory to call $page->save() in the loop.

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...