0

I have declared a custom entity with a schema with a few fields on which is all working as I expect.

I want to remove the label when rendering the entity so have tried the following.

Added some view modes to the entity info hook and although I can see that they exist when I go to manage display none of my entity fields appear. Not sure if this is how it should work or not.

Any ideas?

2
  • Did you use drupal.org/project/eck module?
    – milkovsky
    Aug 20, 2014 at 23:34
  • No I'm using entity api and a custom entity, I would like to be able to build different view modes in code but I don't think it is possible. I did find a solution see below. Aug 21, 2014 at 8:48

1 Answer 1

0

The below function stops a custom entity label from being rendered based on the view mode.

function HOOK_entity_view_alter(&$build, $type) {
  if($type == 'YOUR_ENTITY_TYPE' && $build['#entity_view_mode']['view_mode'] == 'YOUR_VIEW_MODE'){
    $build['#page'] = TRUE;
  }
}

Your Answer

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

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