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.
It would be nice to have the entity reference support in ctools page manager's contexts panel like Relationships.
Comment | File | Size | Author |
---|---|---|---|
#8 | entityreference-add-ctools-relationships-1258502-8.patch | 8.16 KB | das-peter |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedThanks for reporting this. Yes, I would like to see this happen. Should be relatively easy (look at the existing relationships in CTools for inspiration). Patches welcome!
Comment #2
BenK CreditAttribution: BenK commentedSubscribing
Comment #3
Itangalo CreditAttribution: Itangalo commentedI can only agree with Damien and others, this would be great. :-)
Comment #4
Shadlington CreditAttribution: Shadlington commentedSubbing
Comment #5
mansspams CreditAttribution: mansspams commentedThis should not be hard at all. What kind of entity reference support we need? Normal and reverse? Or more kinds? Some interface mockups would be helpful.
Comment #6
Itangalo CreditAttribution: Itangalo commented@mansspams: Just normal would be fine, if reverse are included it would be awesome. For multiple-value fields, the normal approach (so far) has been to pick the first value – so I guess that would be good in this case as well.
Comment #7
Taxoman CreditAttribution: Taxoman commented+1
Comment #8
das-peter CreditAttribution: das-peter commentedI just looked into
ctools/plugins/relationships/entity_from_field.inc
and the attached patch is basically just a copy&paste of it - with some small modifications.First tests look promising - would be great if someone else could give this a try / review.
Comment #9
Damien Tournoud CreditAttribution: Damien Tournoud commentedThanks das-peter! This looks great.
Any reason why those don't use
field_info_field()
andfield_info_instance()
? The read versions are uncached and kind of internal to the Field API.Comment #10
das-peter CreditAttribution: das-peter commentedThe idea behind using
field_read_fields()
insteadfield_info_fields()
was to be able to fetch all fields with the field typeentityreference
.With
field_info_fields()
we need to iterate over all existing fields.And to use
field_info_field()
we need to know the field name - but how could we without usingfield_read_fields()
/field_info_fields()
?But I definitely wasn't aware that
field_read_fields()
is uncached - looks like this comes down to a simple question of performance. If iterating over all existing fields is faster than thefield_read_fields()
we should change the code.Or is there even another way to get the all fields of a specified field type?
Comment #11
amateescu CreditAttribution: amateescu commentedJust wanted to let you know that I posted a patch for ctools that implements this functionality: #1315046: Add tools to help find all field definitions of a specified field type.. Earl said on IRC that he's ok with it, but I guess an extra review can't hurt :)
Comment #12
das-peter CreditAttribution: das-peter commentedIndeed that would be a handy function.
However, since we're mainly talking about performance here (if I didn't miss something) I'd go directly with an own loop ;)
Comment #13
amitaibuOh my, how did I miss this issue :/ -- #1340748: Add CTools relationship
Comment #14
Damien Tournoud CreditAttribution: Damien Tournoud commentedCan anyone clarify the relationship between this and #1340748: Add CTools relationship?
Comment #15
Damien Tournoud CreditAttribution: Damien Tournoud commentedOk, duplicating this in favor of #1340748: Add CTools relationship.
Comment #16
sirviejo CreditAttribution: sirviejo commented#8: entityreference-add-ctools-relationships-1258502-8.patch queued for re-testing.
Comment #18
amateescu CreditAttribution: amateescu commentedWtf?