Programmatically set Panelizer View Template on Node I have panelizer installed so that I can panelize the full content views on a node by node basis on my content types. For example I have a news content type but I have a default panelizer view mode and I have a 'press release' version meant for the news nodes that are considered press releases.

I'm attempting to perform a query on them so I can programmatically set the view modes in bulk instead of having to go through each node and do it manually, but I'm having trouble. The machine names of the views are 'news' and 'press_release' and I'm attempting to change them like so

$node-&gt;panelizer-&gt;view_mode = 'press_release'; 
$node-&gt;save();


But it doesn't seem to have any effect. How would I programmatically change the panelizer view mode on a node?

UPDATE:
I used $node->panelizer->getValue(); and this is what I received.

string(4) "news"
array(2) {
  [0]=&gt;
  array(3) {
    ["view_mode"]=&gt;
    string(4) "news"
    ["default"]=&gt;
    string(4) "news"
    ["panels_display"]=&gt;
    array(0) {
    }
  }
  [1]=&gt;
  array(3) {
    ["view_mode"]=&gt;
    string(4) "full"
    ["default"]=&gt;
    string(13) "press_release"
    ["panels_display"]=&gt;
    array(0) {
    }
  }
}


It seemed like instead of getting the view_mode that is set I got every view mode which made me think Iwas on the wrong path.
It turned out the output of $node->panelizer->getValue(); was giving me a clue that I missed. 

I had forgotten that there were different panelizer templates for different view modes.

I was able to accomplish what I needed with

    $panelizer_arr = $node-&gt;panelizer-&gt;getValue();
    for ($i = 0; $i &lt; count($panelizer_arr); $i++) {
        if ($panelizer_arr[$i]['view_mode'] == 'full') {
            $panelizer_arr[$i]['default'] = 'test_display';
        }
    }
    $node-&gt;panelizer = $panelizer_arr;
    $node-&gt;save();