Custom view mode based on domain

This example actually doesn't even depend on display suite but plays nicely together.
Domain_access module is required.

function MYMODULE_entity_view_mode_alter(&$view_mode, $context) {
  global $_domain;
  if ($context['entity']->type == 'MY_CONTENT_TYPE' ) {
    if ($_domain['machine_name'] == 'MY_DOMAIN_MACHINE_NAME') {
      $view_mode = 'MY_CUSTOM_VIEW_MODE';
    }
  }
}

See also: https://www.drupal.org/node/1490618#comment-9269967

About

This is the company blog of
Drupal specialist Merge.nl

We are located in Breda (Netherlands) and build websites using Drupal. More about us.

Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.

Creative Commons License

Recent Comments

Social