2

I am using Display Suites. I have created a custom view mode and have made it available to the user display per Display Suite documentation, but I cannot figure out how to apply the custom view mode to the user display. It always shows in the default view mode.

If I were editing a node, there would be a vertical tab called Display Settings that would have a field for selecting the view mode to use. When editing an existing user profile, there is no Display Settings tab.


In various Drupal issues queues, specifically Display Suites, Panels and Profile 2, other users have asked essentially this same question: How do I assign a custom view mode to the user profile display?

Is the Drupal core responsible for user data and display? Perhaps the problem lies there instead of with whatever module.

  • Maybe edit user-profile.tpl.php to include your view? – Daniel Rogers Dec 10 '13 at 21:40
  • Thanks @Daniel Rogers. My issue is that I want to use different view modes to display the user profile differently in different places. I can add the view to the tpl.php, but I still can't use view modes on the user profile the way they are meant to be used. – mastoll Dec 11 '13 at 4:49
1

The question is too old, but for those who are still looking similar functionality. We can implement hook_entity_view_mode_alter in our custom module and change the rendered view mode dynamically. Check sample below:

/**
 * Implements hook_entity_view_mode_alter().
 */
function MODULE_NAME_entity_view_mode_alter(&$view_mode, $context) {
  // For nodes, change the view mode when in full display mode.
  // Add/Remove any condition based on requirement.
  if ($context['entity_type'] == 'node' && $view_mode == 'full') {
    $view_mode = 'teaser';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.