Is this a safe way to copy a page?

I have a code that looks kind of like this:


Instead of a manual array I use a content toArray:


Is it totally safe to use to copy a page or is there cases where this will fail?

1 Like

Should be fine. But please note that you need to copy files manually. Also, you might need to make the template dynamic.

I guess you wrap the code within a try/catch block anyway to be able to handle errors?

@lukasbestle Yes, I’m in luck. I just need the content file and it seems to work fine, even with a structure field.

@texnixe I’m using it inside a panel hook. Right now I don’t want to throw errors, at least not echo anything because then the panel will hang. I still find it hard to debug hooks. I can only hope it will be easier in the future. Right now I write something to a file to see how far the hook made.

Thanks to both of you!