Jump to content

Page reference of cloned page


Frank Vèssia
 Share

Recommended Posts

 Hello, I'm struggling to understand why this is not working.

I'm cloning a page (with children) and assing it as page reference to another page but the page reference don't change.

 

$call = $pages->get(123);

$new_report = $pages->clone($report);
$new_report->of(false);
$new_id = uniqid();
$new_report->title = $new_id;
$new_report->name = $new_id;
$new_report->save();
$new_report->of(true);

$call->of(false);
$call->report = $new_report;
$call->save();
$call->of(true);

 

Link to comment
Share on other sites

it's working for me with the code below
Please check for typos.
Is you page reference filed name really report?
And is it a single or multiple page?

	$call = $pages->get(1234);
	$report = $pages->get(4321);
	
	$new_report = $pages->clone($report);
	$new_report->of(false);
	$new_id = uniqid();
	$new_report->title = $new_id;
	$new_report->name = $new_id;
	$new_report->save();
	$new_report->of(true);
	
	$call->of(false);
	$call->report = $new_report;
	// $call->report->add($new_report);
	$call->save();
	$call->of(true);

 

Edited by ngrmm
added code
  • 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   1 member

×
×
  • Create New...