Jump to content

Problem by adding new page with PageTable field via API


diegonella
 Share

Recommended Posts

I am using the following code:



$new_pt = new Page();
$new_pt->parent = "/opt/";
$new_pt->template = "pt_template";
$new_pt->name = uniqid('pt-', true);
$new_pt->title = "Title ".time();

if ( $new_pt->save()) {
$page->of(false);
$page->pt_field->add($new_pt);
$page->save();
}


and it turns out I inserted 2 pages, and I can not know where the problem.

I'm using 2.6.1 PW

Could give me a help, where my error.

thanks

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

×
×
  • Create New...