I'm not looking to use Views for this challenge here but simply to add a check for a value of a field on the viewing user's profile and then to select the correct view mode from Display Suite for that node depending on that value. What would I have to do to accomplish this?

1 Answer 1


Are you looking for code or just the approach? One approach would would be to use HOOK_entity_view_mode_alter(&$view_mode, $context) in a custom module:

  1. Check that the user is logged in
  2. Check that the user is viewing the right kind of node
  3. Load the user and get the profile field value
  4. Based on the field value, set the view mode ($view_mode = 'custom')
  • Great! I've never created a module of my own but I guess I should be able to work that out.
    – BassPlaya
    Commented Nov 20, 2013 at 8:49
  • If you're using Drupal often, and don't mind working with PHP, it's totally worth it to learn how to create a module. There are lot's situations where it's the fastest way to solve a problem. Let me know if you want sample code for changing a view mode.
    – Dave Bruns
    Commented Nov 20, 2013 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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