Jump to content

Recommended Posts

Posted

 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);

 

Posted
3 minutes ago, ngrmm said:

@Frank Vèssiaplease check if your page reference field is accepting the template of the new cloned page.

yes is the same as the previous one, I just clone the page and reassing the new one. Very strange...

Posted (edited)

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

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
  • Recently Browsing   0 members

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