Is there a way to define a custom display setting under Manage Display on a content type? I want to hide certain fields (when viewing, not editing) from non-authenticated users. I know I can do this with a custom .tpl file; just wondering if there's another way (without additional modules.)

  • 2
    You'll need to implement some sort of field permissions for this, and rather than reinvent the wheel I can't recommend Field Permissions strongly enough. If you're dead set against adding another module, have a look at the code in that one to see how it handles such things. The manage display page doesn't even need to come into it...the fields that anonymous users don't have access to simply won't show up when they view the entity page
    – Clive
    Aug 9, 2012 at 14:41
  • Yeah, I know about Field Permissions; I just wondered if there was a way to create a new custom display choice.
    – EmmyS
    Aug 9, 2012 at 15:25
  • I've added an answer for how to do that (was too long for a comment), I'm not quite sure how you'll integrate that with your permission requirements but hopefully it'll get you started
    – Clive
    Aug 9, 2012 at 15:35

1 Answer 1


As far as implementing a new view mode yourself goes it's pretty easy, without any contrib modules.

You can implement hook_entity_info_alter() to add a custom view mode to any entity. For example this code adds a new view mode called "Test View" to the node entity type:

function MYMODULE_entity_info_alter(&$info) {
  $info['node']['view modes']['test_view'] = array(
    'label' => 'Test View',
    'custom settings' => TRUE

After a cache clear that view mode will appear in all the places you'd expect (manage display, views, etc.)


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.