I want to change the view mode of node programmatically. I used hook_preprocess_node(&$vars)
and set the view mode:
function moduleName_preprocess_node(&$vars) {
// if conditions to apply particular view mode
$vars['view_mode'] = 'teaser';
$vars['elements']['#view_mode'] = 'teaser';
}
But this is not working as expected. Am I missing something here?