Hi,
one of the reasons why I never end up using EVA is that it's a preprocess field.

The main problem with that: There can be situations where EVA is processed, when it is not actually needed. This can lead to performance issues in some cases.

The other problem is, it may be processed at the wrong time, when the main entity is not processed yet.
See #1570698: EVA not showing up with ds_extras "Region to block" (because it's a preprocess field).

I mostly want to use EVA within Display suite, where being a preprocess field is not really necessary.

---------

The alternative to EVA is views content panes. It does not have the above problems, but it is a pain to configure in Display suite, with the ctools context overkill.

I think the best solution would really be if EVA was not a preprocess, but a regular DS field. Or, it could even let the admin choose, if it wants to be preprocess or not :)

Maybe in a new 7.x-2.x branch?

Thanks!

Comments

donquixote’s picture

Just saying, DS + EVA (if it wasn't preprocess) would also be a very nice alternative to views overrides of taxonomy/term/% and the like.

These views overrides tend to have their own performance issues, requiring to load the full view for a simple access check (due to views_arg_load). At least, this was the way it worked, last time I checked.

mkadin’s picture

donquixote’s picture

Actually there are two options
hook_ds_fields_info()
hook_field_extra_fields()

I personally found it easier to use hook_ds_fields_info().
Somehow the extra fields thing did sometimes not work.
On the other hand, extra fields work outside of ds.
(and this is not what EVA does currently, or is it?)

mkadin’s picture

Yes EVA does currently use hook_field_extra_fields to register the embedded view for the normal 'Manage Display' tab for an entity without ds. I'm guessing both cannot be used in tandem, but I'll play around with it.

donquixote’s picture

Ok, I think finally I understand better what hook_field_extra_fields() actually does :) It only adds rows to the field UI, but does not really create anything on the rendered entity. This is why I always thought it doesn't work :)

EVA implements hook_entity_view_alter(), to attach the fields to the entity.

The cost is:
a) Time spent to figure out which views displays to attach to the entity. This uses views_get_applicable_views(), which is expensive. Even if the view is not used.
b) Time spent to render the views display. Ok, as I understand, we do actually check for $fields['longname']['visible']. But, if the entity is rendered via ds, using "Region to block", then the rendering was in vain.
c) EVA not showing up with ds_extras "Region to block".

I get the idea that the only cure for (c) is hook_ds_fields_info(). However, this only works with ds-enabled view modes.

For (a), and (b), we could try to do something smart:

Instead of eva_get_views(), we loop through $fields, as returned by field_extra_fields_get_display().
Whenever we find a visible field, we extract view name and display id from the field name, and attach a cheap placeholder to the entity display. That is, a renderable array with a #process or #theme function, and a setting for view name and display id, and anything else we need for the rendering.

The #process or #theme does only get called when the field needs to be rendered. Only then do we load, execute and render the views display. I hope this prevents rendering in case the field sits in a ds "Region to block".

In addition, to solve (c), EVA could implement hook_ds_fields_info() and register the field as a ds field. So we would have a different mechanic to render the thing in ds mode, than in regular field mode.
On the other hand, we don't want the field to show up duplicate in ds field UI. So we need to find a way to remove the regular one.

donquixote’s picture

An alternative to EVA (but only for ds-enabled view modes) is
Views content DS

redndahead’s picture

Issue summary: View changes

Marking as duplicate as #1296610: Prevent disabled fields from being rendered (performance)

Combining all issues into one.

redndahead’s picture

Status: Active » Closed (duplicate)
Related issues: +#1296610: Prevent disabled fields from being rendered (performance)