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.
via the entity property info API we have knowledge about entity relationships (independently from any schema). Let's expose this as a CTools relationships also?
We should make sure we do not duplicate any existing ctools relationships though. Not sure whether we can do this with CTools' API? Worst case, we could still make it opt-in only by only providing this if a special flag is set in the entity references' property info.
Comment | File | Size | Author |
---|---|---|---|
#7 | d7_entity_ctools_relationship.patch | 6 KB | fago |
#6 | d7_entity_ctools_relationship.patch | 6 KB | fago |
Comments
Comment #1
fagoRelated issues:
#1340748: Add CTools relationship
#1834920: Create profile2 ctools relationship context from node
Comment #2
andypostHow to make this generic? Some entities does not have bundles.. it seems we need 2 kinds of relations.
When referenced entity have bundle we should provide a settings form and defaults.
Comment #3
fagoDoes CTools even handle bundles? Isn't exposing the entity reference enough?
Comment #4
andypostProbably enough but all ctools' shipped plugins are have custom plugins/implementations for that purpose (choose a bundle)
Comment #5
DamienMcKennaFor anyone else who finds this issue, andypost's patch in #1011370 may help sites as a temporary solution until this one is resolved.
Comment #6
fagook, took a stab on this. Here is a general plugin that allows one to expose *any kind* of selected data based on the metadatawrappers - quite useful as you don't have to write custom relationship plugins for all that supported stuff any more :-)
Comment #7
fagoSmall update to better deal with empty lists.
Comment #8
fagoNote: This works great with #2180775: Allow views argument from context to make use of context arguments to handle multiple-valued contexts as views arguments.
Comment #9
jsibley CreditAttribution: jsibley commentedIs this supposed to solve https://drupal.org/node/1011370 instead of the patch that was proposed there?
If so, when will it be committed here and could there be an update in the other issue queue?
I believe that there are a number of people who have been waiting for a way to integrate profile2 and panels and it would be helpful to commit and document a workable, stable, solution.
Thanks.
Comment #10
fagoYeah, it's an alternative to #1011370: Ctools relationship from user - it's more powerful but provides worse UX. So we might want to add #1011370: Ctools relationship from user as well.
Comment #11
TwoDI'm having issues with this line.
I'm testing this with a profiles2 profile called "Instruktörsprofil", and by overriding the
user/%user/
path using Page Manager and Panels, and trying to get the profile as a context for my Variant.The profile's machine name is
instruktorsprofil
and I had no idea what to enter as the "Data selector" when creating the context relationship, so I had a look on the user object with Devel. There was a property called "profile_instruktorsprofil" on the Rendered tab, and the context form accepted this.I picked "instroktor" as my keyword and was able to do things like adding the suggested "%instroktor:pid" token to my title for testing. I was also able to add one of my profile fields to the Panel content.
However, when view the user page, the title is missing the token value, and the field is not rendered. Instead I get this error (twice):
I inserted
dpm($context, 'context');
to check the value of$context->plugin
, and the value is just "user
".$context->data
holds the user object.Am I missing something or is this a bug?
EDIT: It works great if I do this instead of the line above:
Comment #12
fago@Twod: hm, sounds like you debugged the wrong context object?
But yeah, you have to know what to enter as there is no UI for listing data selectors. I guess easiest way is using rules and its data selector to find what you need and then enter it here.
Anyway, this works very well for me (have it running on a production site for ages) and is quite powerful. As it cannot have any side-effects as long as the plugin is unused, I'm going ahead and commit this.
Comment #14
fago