Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Click sorting, filters and sorts are disabled for non-database fields. But one might want to use a custom handler to support this functionality for fields which are provided by by for instance hook_entity_property_info_alter(). Below is a patch which allows users to register their custom handler is the entity metadata.
Example of usage:
function my_module_entity_property_info_alter(&$info) {
$properties = &$info['my_entity']['properties'];
$properties['under-age'] = array(
'label' => t('Is under-age'),
'type' => 'boolean',
'description' => t('Boolean value indicting whether the person is under-age.'),
'getter callback' => 'my_module_entity_getter_callback',
'views' => array(
'filter' => 'my_module_filter_under_age',
),
);
}
Full support for entity metadata must imho be a goal of efq_views. As far is a know there is no other (simpler) way to achieve this.
Thanx in advance for reviewing!
Comment | File | Size | Author |
---|---|---|---|
#5 | add_custom_views_handlers-1138542-5.patch | 1.99 KB | colan |
efq_views-metadata_handlers.patch | 1.14 KB | xatoo | |
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedI agree in principle.
However, let's first wait for #1077148: add an entity-view row plugin to land in Entity API, because I'm attempting the same thing there (keys in the metadata to override the handlers determined by Entity API)
Comment #2
colanI support we can reopen this now that the other issue is closed (fixed)?
I need to figure this out for my current project so I'll see if the above patch (now 3 years old) is still useful.
Comment #3
colanThe above patch applies cleanly, but that's misleading, as errors like this start showing up:
Invalid argument supplied for foreach() efq_views.views.inc:184
The code looks like it's supposed to be inserted into _efq_views_get_property_data(), but that function no longer exists.
As mentioned above, we may not need this as it looks like it can be done through the Entity API as per Views integration. I'll try that and see what happens. If it works, we can close this.
Comment #4
colanThe Entity API approach doesn't work because it combines both the EFQ filter and the custom filter into an array. This of course causes problems because code further down the line is expecting a class name string, not an array.
I'll try to come up with a solution for this.
Comment #5
colanThe problem is the array_merge_recursive() call when combining data from this module and the Entity API. The latter processes the custom views_data() methods.
So the fix is to rework the above patch for modern times. See attached.
Comment #7
colanNow in dev.