From 13f16ae3423087824118e1e5c07f88396a85c8f7 Mon Sep 17 00:00:00 2001 From: webchick Date: Sun, 30 Sep 2012 20:37:55 -0400 Subject: Issue #1154382 by Berdir, barraponto, acouch, swentel, LoMo, DamienMcKenna, chx: Fixed View mode no longer can be changed. --- modules/system/system.api.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modules/system/system.api.php') diff --git a/modules/system/system.api.php b/modules/system/system.api.php index dda62f7ac..7bf637ec0 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -465,6 +465,24 @@ function hook_entity_view_alter(&$build, $type) { } } +/** + * Change the view mode of an entity that is being displayed. + * + * @param string $view_mode + * The view_mode that is to be used to display the entity. + * @param array $context + * Array with contextual information, including: + * - entity_type: The type of the entity that is being viewed. + * - entity: The entity object. + * - langcode: The langcode the entity is being viewed in. + */ +function hook_entity_view_mode_alter(&$view_mode, $context) { + // For nodes, change the view mode when it is teaser. + if ($context['entity_type'] == 'node' && $view_mode == 'teaser') { + $view_mode = 'my_custom_view_mode'; + } +} + /** * Define administrative paths. * -- cgit v1.2.3