8.4.2 How to change page type template programmatically

Permalink 1 user found helpful
I have a page of a type Blog Entry with a default template set to 'full'.

How can I change the page type template programmatically to, say, 'right_sidebar'?

Thank you.

linuxoid
 
shahroq replied on at Permalink Best Answer Reply
shahroq
$page = \Page::getByID(1);
//echo $page->getPageTemplateID();
//echo $page->getPageTypeID();
$page->update(array(
    'pTemplateID' => 7, //new page template id
    'ptID' => 10 //new page type id
));

https://github.com/shahroq/whale_c5_cheat_sheet#update-a-page...
linuxoid replied on at Permalink Reply
linuxoid
So simple??? If I only knew... ))) Thank you.