Changing pagetype programatically

Permalink
Hi

I was searching for an answer for this for a while now and it might be obvious but I can't figure it out.

How can I change the pagetype of a page programtically?

something like
$page->setPageType($pagetypeHandle);

Any help is greatly appreciated

Thanks

shotrox
 
csebe replied on at Permalink Reply
Hi,

I can see that the "update" method in the Page object offers the possibility to change the "Page Template ID".
See here:http://www.concrete5.org/documentation/developers/5.7/working-with-... and here:http://concrete5.org/api/source-class-Concrete.Core.Page.Page.html#...

Now, in the new 5.7 context of having Page Styles separated from Page Templates, I am not sure if this is what you need.
As I can see, in the GUI you can also change only the template (i.e. layout) of a page, and not its type, so it should be the same operation.

(Good question actually: are the page types used only at page creation moment and no info regarding the page type a certain page was spawn from, is kept afterwards?
I mean, a page type is practically a page template preloaded with some global blocks... So, after adding a page to C5, it might be that only its template and blocks are saved in the database but not the type. This would explain also why altering a page type is not actually modifying the already created pages, but only the new to be created ones.
Any Guru can enlighten us on this?)

Cheers,
Lian