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.

#7 d7_entity_ctools_relationship.patch6 KBfago
PASSED: [[SimpleTest]]: [MySQL] 628 pass(es). View
#6 d7_entity_ctools_relationship.patch6 KBfago
PASSED: [[SimpleTest]]: [MySQL] 628 pass(es). View


fago’s picture

andypost’s picture

How 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.

fago’s picture

Does CTools even handle bundles? Isn't exposing the entity reference enough?

andypost’s picture

Probably enough but all ctools' shipped plugins are have custom plugins/implementations for that purpose (choose a bundle)

DamienMcKenna’s picture

For anyone else who finds this issue, andypost's patch in #1011370 may help sites as a temporary solution until this one is resolved.

fago’s picture

Issue summary: View changes
Status: Active » Needs review
6 KB
PASSED: [[SimpleTest]]: [MySQL] 628 pass(es). View

ok, 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 :-)

fago’s picture

6 KB
PASSED: [[SimpleTest]]: [MySQL] 628 pass(es). View

Small update to better deal with empty lists.

fago’s picture

Note: This works great with #2180775: Allow views argument from context to make use of context arguments to handle multiple-valued contexts as views arguments.

jsibley’s picture

Is this supposed to solve 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.


fago’s picture

Yeah, 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.

TwoD’s picture

+++ b/ctools/relationships/
@@ -0,0 +1,153 @@
+  list($part1, $entity_type) = explode(':', $context->plugin);

I'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):

Notice: Undefined offset: 1 i entity_entity_property_context() (rad 37 av /home/henrik/Projekt/Jobb/TibroBK/drupal/sites/all/modules/entity/ctools/relationships/

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:

  if (strpos($context->plugin, ':') !== FALSE) {
    list($part1, $entity_type) = explode(':', $context->plugin);
  else {
    $entity_type = $context->plugin;
fago’s picture

@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.

  • fago committed 4a64263 on 7.x-1.x
    Issue #1874006 by fago: Expose entity references as CTools relationships
fago’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.