0

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

0

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')
2
  • Great! I've never created a module of my own but I guess I should be able to work that out. 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. Commented Nov 20, 2013 at 17:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.