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.
I'm having a Pager manager page with a user context. Additionally I added the relationship 'Profile from User (on profile.uid)' for retrieving the profile2 object.
Now when viewing the page, the wrong profile is loaded. Instead of using the UID to join on the profile.uid column, directly profile.pid is used, leading to the wrong profile object (the profile with pid = uid is loaded)
Comment | File | Size | Author |
---|---|---|---|
#27 | ctools-profile2_from_user.inc_.patch | 2.14 KB | druvision |
#28 | profile2.module.patch | 465 bytes | druvision |
#26 | ctools-new-file-1273026-10.patch | 2.07 KB | druvision |
| |||
#26 | ctools-profile2_from_user-1273026-10.patch | 3 KB | druvision |
#14 | ctools-profile2_from_user-1273026-10.patch | 3 KB | pwaterz |
Comments
Comment #1
bambilicious CreditAttribution: bambilicious commentedSubscribing.
Comment #2
mh86 CreditAttribution: mh86 commentedThe problem comes from the reverse relations in entity_from_schema contexts. It takes the UID from the user object and loads the profile2 with entity_load('profile2', array($uid)), which can't work, as the profile ID is needed instead. Of course the other way round - using the UID from the profile entity to load the user - works.
Comment #3
bambilicious CreditAttribution: bambilicious commentedHave you come up with any possible way to attack this problem?
Comment #4
mh86 CreditAttribution: mh86 commentedI'm using #1301080: Generic entity from view relationship handler in the meanwhile, but I think it's rather a workaround for such a simple use case.
Comment #5
bambilicious CreditAttribution: bambilicious commentedThanks, I'll have a look.
Comment #6
scottsawyerHas anyone tested the patch?
I have 2 Profile2 types "Main", "company". I would like to have a context for each and selection rule based on they profile type. However, I can only seem to get the Main profile type to respond to my Panel.
Thoughts?
Comment #7
nagiek CreditAttribution: nagiek commentedCan't we just write our own plugin? profile2_from_user? We'd have to adjust the form to specify the profile2 type you want loaded, and boom!
Comment #8
nagiek CreditAttribution: nagiek commented.
Comment #9
nagiek CreditAttribution: nagiek commentedHere's the patch and the file for the new relationship. Just rename the file to .inc and place it in the plugins/relationships folder.
Comment #10
nagiek CreditAttribution: nagiek commented.
Comment #11
nagiek CreditAttribution: nagiek commentedComment #12
merlinofchaos CreditAttribution: merlinofchaos commentedProfile2 is a module, not core; as such, the policy of CTools is to require this kind of support to either be in the module or in a glue module maintained by others. I am unable to accept maintenance of code like this. It takes ages just to keep up with changes in core, I am simply incapable of keeping up with changes in other code.
There are rare circumstances that I'll support modules directly, typically when it's not possible to put the code anywhere else, but this isn't one of them since these plugins are very portable and can live anywhere.
I highly recommend you submit this to profile2 and/or make a module. If you do make it a module and need help getting through the review process to get approved git access, I can try to use a little of my community karma to speed things up.
Comment #13
wjaspers CreditAttribution: wjaspers commentedMoving to correct queue.
Comment #14
pwaterz CreditAttribution: pwaterz commentedThe patch above didn't add the ctool plugin hook. Here is an updated patch
Comment #15
andypost#14 is a part of #1011370-21: Ctools relationship from user
Suppose we need to mark this issue as duplicate
Comment #16
andypostComment #17
zmove CreditAttribution: zmove commentedReopen because that's not the same issue. The profile2 module just need to have the relationship defined as the patch provide and this patch fix it.
Comment #18
fago#1834920: Create profile2 ctools relationship context from node
Comment #19
zmove CreditAttribution: zmove commentedNot sure it's a duplicate. In that case it create the relationship from user (profile2_from_user.inc), in the linked issue it's from node (profile2_from_node.inc).
I reoped just to have confirmation it's a duplicate. If it's different issues, I can confirm that the patch in #14 works like a charm.
Comment #20
fagoTrue sry, still we have #1011370: Ctools relationship from user - let's track this over there.
Comment #21
andypost@zmove Relation to profile from node should be build with relation from user from node, so @fago is right - let's focus on #1011370: Ctools relationship from user
Comment #22
zmove CreditAttribution: zmove commented@fago @andypost Thank you for answers, I will follow that.
Comment #23
operations CreditAttribution: operations commentedPatch #14 works and solved my problem (profile2 fields not working well with panels).
Comment #24
Achille CreditAttribution: Achille commentedSo, at this time, there is NO solution to this problem, correct?
Thanks
Comment #25
operations CreditAttribution: operations commentedAs far as I think :)
Comment #26
druvision CreditAttribution: druvision commented#14 works for us, so I am repackaging the fix in this post.
- The 1st file is a new file under ctools/plugins/relationships/profile2_from_user.inc which should be run from the ctools directory.
- The 2nd file is a patch to profile2.module.
Comment #27
druvision CreditAttribution: druvision commentedThis is the 1st file from comment #26 (added ctools plugin), in a patch format
Comment #28
druvision CreditAttribution: druvision commentedThis is the 2nd file from comment #26, in a patch format (function added to profile2.module)
Comment #29
ledom CreditAttribution: ledom commentedReopen, duplicates not solved this issue.
I try dev version, which solved #1011370 but still need to add inc file from #14 to get profile2 fields showing into panel (if not, no context from profile2)
After each upgrade, I lose this file...
Comment #30
kenorb CreditAttribution: kenorb commentedComment #31
kenorb CreditAttribution: kenorb commentedComment #32
MorinLuc0 CreditAttribution: MorinLuc0 as a volunteer and at Coldfront Labs Inc. commentedBeen reviewed and from what I can see it has been applied already to the dev branch, Just waiting on a new release once 2227945 has been fixed it can be marked as closed.
Comment #37
mlncn CreditAttribution: mlncn at Agaric commentedAs noted by MorinLuc0 this was applied to the dev branch and that is why the patch started failing. This is fixed.