Currently the count field has to be on the same entity type as the entityreference field. Expand the module so that the count field can be placed on any entity type.

There are several parts to this.

The first part is relatively easy - changing the list of fields to just list all entityreference fields. However, shouldn't it work off the field instance instead of the field base?

The second part is more difficult - limiting the list of bundles that should be considered for the count. Is there any need for this?

The third part is the query in entityreference_count_field_formatter_view(). That needs to work off EFQ.

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Issue summary: View changes
damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new6.88 KB

WIP. This works for me with a counter field on a Fieldable Panels Pane entity that counts occurrences of a reference field on a User entity.

damienmckenna’s picture

StatusFileSize
new1.83 KB
new8.53 KB

Had to update entityreference_count_references_update() to not require the $entity->type value but instead use entity_extract_ids() to get the bundle.

khalor’s picture

Status: Needs review » Reviewed & tested by the community

#4 working great for me (with entity reference fields on a user being counted by the node they refer to).

WorldFallz’s picture

I'd like to get this committed in preparation for rolling a release. Which of the 3 items is included in the patch-- looks like at minimum, part 3 didn't make it in.

knipnehpets’s picture

#4 works a dream (counting taxonomy terms referenced by commerce products). Cheers.
Are you going to release a new dev version (currently dev version pre-dates the beta version).