0

I have a node type called fotogallery. In this node type there is a field of type "field collection". With hook_field_formatter_view() I create a custom output for this field.

Now, the same node type is linked to another node type via entity reference. In this case I want to create another type of output for the "field colletion" field. But how I (drupal cms) can know if I'm inside node type "fotogallery" or I'm inside an entity reference ?

Do I need to load the current node (via node_load(arg(1)) and see the "type" value?

1 Answer 1

0

A Field Formatter has no awareness of when it's used. It's simply just a unique way to display a field.

You want to use something like Entityreference ViewMode Selector. And create 2 formatters for the Field Collection. 1 formatter is the default output for collections, 1 formatter is the viewed as entityreference formatter.

When you set the entityreference, you would set the formatter as needed.

1
  • Thanks for the reply but Entityreference ViewMode Selector is a useless module in my situation.
    – ZioBudda
    Commented Jul 13, 2015 at 20:33

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.