Duplicate singelton

I can duplicate entry

I can duplicate collection


There is no easy method, yet.

You can copy and paste the field definitions from /storage/singleton/old.singleton.php to /storage/singleton/new.singleton.php. Now the fields are cloned.

If you want to clone the data, too, just get the data from the old one and save it to the new one.

The PHP way:

// get data from singleton "old"
$data = $app->module('singletons')->getData('old');

// save data to "new"
$app->module('singletons')->saveData('new', $data);

Here is a simple way to save singletons via api:

Yes… Understand Thanx…

This topic goes back about a year, since then is there an easy way to duplicate a singleton on front end ?

I have a singleton that has inside it a number of components, and I need many singletons with same basic compenents and I will then manually update data inside those components. I understand duplicating the singleton .php file and renaming it creates the basic singleton in Cockpit, but none of the components are there.

I don’t know how to use the api to do what is suggested above so wondering if there has been developed an easier method for this all important task. Thanks so much

I would also like it if there was a function directly in the interface to duplicate a singleton. that should be easy to implement.