Views integration
Membership entity Views data
Class: Drupal\crm_membership\MembershipViewsData
File: src/MembershipViewsData.php
The Membership content entity exposes Views data via this handler (declared on the entity type). In addition to the default entity base table and field data:
- Label field — A synthetic
labelfield is added to the base table. It usesidas the real field and the custom field plugincrm_membership_labelto display the membership label (e.g. “Organization membership for Contact A (Type name)”). - Default field — The base table’s default field is set to
labelinstead ofid, so new Views of memberships show the label by default.
Custom field plugin: Membership label
Plugin ID: crm_membership_label
Class: Drupal\crm_membership\Plugin\views\field\MembershipLabel
File: src/Plugin/views/field/MembershipLabel.php
Views field that renders the membership entity’s label. Option “Link to entity” allows linking the label to the membership’s canonical URL. Use this field when building Views that list memberships and you want the same label as the entity’s label() method.
Optional view: membership periods for membership
The module can install an optional View configuration:
Config: config/optional/views.view.membership_periods_for_membership.yml
When the View module is enabled, this view is created. It lists membership periods in the context of a membership (e.g. for use on a membership detail page or in admin). The exact display and filters are defined in that YAML file.
To customize or extend membership or period listings, create a View that uses the crm_membership or crm_membership_period entity type; the base table and the custom label field are available as described above.