This project is not covered by Drupal’s security advisory policy.

What is this?

This module provides an easy way for an entity to keep track of how many other entities are currently referencing it through Entity Reference fields attached to other entities.

This module is an adaptation of Nodereference Count module, porting the same functionality to Entity References catering to the added flexibility in Drupal 7 to reference any entity type -- not only nodes.

How it works

This Entity Reference Count is in-and-of itself, just another field type (called "entityreference_count" in the code) that may be attached to any Drupal entity. The field may be configured to select which referencing entity types and fields you want to aggregate in the count. The counter field is automatically re-calculated when the referencing or referenced entity get inserted, updated or deleted. The Entity Reference Count's numeric field value may be enabled, displayed and manipulated via view modes, through the "Manage Fields" interface provided by Drupal core's Field UI, and has built-in Views integration.

Installation

  • Copy entityreference_count to your module directory and then enable on the admin modules page.
  • Be sure you have at least one EntityReference field configured using the "Simple (with optional filter by bundle)" option and then add an EntityReference_Count field to a content type that is referenced by a EntityReference. Check the boxes for the EntityReference fields that should be counted.
  • You will need to re-save any existing entities or their referencing entities in order to update the count that will be empty for all the entities that exist previous to the installation of this module.

Note

Currently this module only works with entityreference fields configured to use the "Simple (with optional filter by bundle)" option. It does not work with the "Views: Filter by an entity reference view" option. This may be addressed in a future release.

Credits

  • Thanks to all the hard work of Brendan Andersen (gilgabar) who created the Nodereference Count module that introduced the approach to count references. This module is a mere adaptation to make this methodology work with Entity References, which we believe is a more powerful solution than Node References in Drupal 7.
  • The development of this module was sponsored by Bluespark

Project information

Releases