Consequently the relevant alters cant do much useful. Pity.

Comments

catch’s picture

subscribe.

chx’s picture

Status: Active » Needs review
StatusFileSize
new2.5 KB

But fixing this is not hard.

yched’s picture

Status: Needs review » Needs work

Could you provide a use case ?
(why not I guess, but why ?)

- this needs to be altered in hook_field_display_ENTITY_TYPE_alter() as well, and in the existing node_field_display_node_alter() implementation.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

the implementation in node hardly needs a change. we just add more stuff to context but we are fine w not using it.

Use case, sticky posts show an image in teaser, otherwise dont. The fastest way to not show an image is to set the field display to hidden.

Most importantly, why not? :)

yched’s picture

Use case, sticky posts show an image in teaser, otherwise dont

Yes, but

+    'entitie*s*' => $entitie*s*,

field_default_prepare_view() runs in 'multiple entities' mode (that's because hook_field_prepare_view() and hook_field_formatter_prepare_view() typically load additional stuff from the db).
Here field_get_display() is called in the context of several entities and returns one $display. So your alter hook can't separate sticky nodes from non-sticky ones.
That's why I'm wondering about use cases at all.

yched’s picture

StatusFileSize
new3.01 KB

Hm, I was on crack when writing the above.
field_default_prepare_view() runs in 'multiple entities' mode, but calls field_get_display() entity by entity ($id by $id).
So it should be ok, but the additional $context entry is 'entity', not 'entities'

See attached patch (my first patch using git :-p)

chx’s picture

Status: Needs review » Reviewed & tested by the community

Ah ha! Good one, thanks.

sun’s picture

#6: field_get_display_830020.patch queued for re-testing.

tom_o_t’s picture

#6: field_get_display_830020.patch queued for re-testing.

dries’s picture

Status: Reviewed & tested by the community » Fixed

This makes sense to me. Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.