My site has lots of entity reference fields. The option to format the field as rendered content of type teaser is neat, but I would like to have more flexibility (for instance sorting, filtering, pagination). Is there a module with a field formatter that lets me use a view to display entity references? I have searched for it, but found nothing. In case there is no module for this, I will consider writing one (my first!), but I would like to make sure I am not reinventing the wheel before I start coding away.

(I know this could be achieved by creating a block and then moving the block to the right spot, but in my opinion that is quite an ugly solution.)

Any thoughts on this would be welcome.

Comments

nevets’s picture

It sounds like you want to use eva instead of an entity reference field, eva will allow you to associate a view with a field. And speaking of blocks, that approach also works, add the block reference field and you can handle it as a field.

For more control there is display suite and panels, both make it possible to overrider the page display of a node.

AndersEkman’s picture

Thank you for your reply!

I tried EVA and Block reference. Both modules can solve the problem, but they require a bit of extra setup for every field. For EVA I didn't use it instead of Entity Reference, but together with it. I hid the ER field, then attatched a view, that with the help of a relation and a contextual filter only show the entitys referenced in the ER field. Is that the sort of approach you had in mind or am I missing something?

I'm a bit afraid to use DS or Panels - they are sort of game changers to have you manage your site, and a bit to big for a small problem like this. But you are off course right to recommend them.

So I think I will still consider writing a module for it, partly for the fun. Or would that be a completely unnecesarry piece of code?

nevets’s picture

I think since there are existing solutions it would be an unnecessary piece of code.