Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Fixed in Drupal 7.17

Drupal 7.17 introduced the new hook_entity_view_mode_alter rendering this sandbox project unnecessary.

Original Issue:
#1154382: View mode no longer can be changed
Change notice:
Added hook_entity_view_mode_alter() to allow modules to change entity view modes on display

Original Description

Exposes hook_modeswitch_view_alter_node allowing dynamic selection of a view_mode. This is essentially a workaround for http://drupal.org/node/1154382


 * Implements hook_modeswitch_node_view_mode_alter().
function yourmodule_modeswitch_node_view_mode_alter(&$view_mode, $original_view_mode, $node) {
  if (_yourmodule_should_switch_mode($node)) {
    $view_mode = 'yourmodule-yourmode';

Project information