Skip to main content
Post Undeleted by Clive
added 53 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

If you don't want to useAs far as implementing a contrib module (one does exist)new view mode yourself goes it's pretty easy, youwithout any contrib modules.

You can implement hook_entity_info_alter() to add thea custom view mode yourselfto 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.)

If you don't want to use a contrib module (one does exist), you can implement hook_entity_info_alter() to add the view mode yourself. 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.)

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.)

Post Deleted by Clive
Post Undeleted by Clive
Post Deleted by Clive
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

If you don't want to use a contrib module (one does exist), you can implement hook_entity_info_alter() to add the view mode yourself. 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.)