Jump to content

Duplicate template with all settings


Frank Vèssia
 Share

Recommended Posts

Hi.

https://github.com/processwire/processwire/blob/master/wire/core/Templates.php#L303

So it looks like cloning of the template doesn't clone fields context for template fieldgroup.

You can do it by api like


$sourceFieldgroup = $fieldgroups->get('service');
$newFieldgroup = $fieldgroups->get('test');
foreach ($sourceFieldgroup as $field) {
    if($sourceFieldgroup->hasFieldContext($field) && $newFieldgroup->hasField($field)) {
        $contextArray = $sourceFieldgroup->getFieldContextArray($field->id);
        $newFieldgroup->setFieldContextArray($field->id, $contextArray);
    }
}

$newFieldgroup->saveContext();

Probably there is better way but it worked for my case. 

 

  • Like 3
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...