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->panelizer->view_mode = 'press_release';
$node->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]=>
array(3) {
["view_mode"]=>
string(4) "news"
["default"]=>
string(4) "news"
["panels_display"]=>
array(0) {
}
}
[1]=>
array(3) {
["view_mode"]=>
string(4) "full"
["default"]=>
string(13) "press_release"
["panels_display"]=>
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.