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.
Hii, first of all sorry for my bad lang :D
After reading almost all documentation about this module but I still confused :(.
Actually only like this my problem,
1. I create some field for user using profile2 module, like ID number and others, And I only need to display ID Number that I created to author pane. Please help me how to solve it.
2. I need to display user city and province from Location Module to author pane too, How to do this
Let me add what I need with attach image below
Comment | File | Size | Author |
---|---|---|---|
#17 | author_pane_final.PNG | 5.41 KB | System Lord |
#6 | author_pane.PNG | 4.76 KB | System Lord |
ask_for_solve.jpg | 91.75 KB | eboss |
Comments
Comment #1
MichelleThe Author Pane end of this is fairly simple and also well documented. Where the difficulty lies is figuring out how to get the data you need from those other modules. This isn't something I know off the top of my head to tell you. You can try asking in the queues of those modules or in the forum. I'll leave this active for a while in case someone else wants to take the time to dig into this for you but it isn't something I can help you with.
Michelle
Comment #2
jay.lee.bio CreditAttribution: jay.lee.bio commentedEboss, I'm trying to do the same exact thing and just found some related code at https://www.drupal.org/node/1360258, #7. I'll report back if I figure something out.
Comment #3
jay.lee.bio CreditAttribution: jay.lee.bio commentedMan I got so close, but no cigar. I got the following simple field to show up:
But the following is what we want that doesn't work:
If anyone knows what I'm doing wrong, let me know. Thanks!
Comment #4
MichelleI suggest getting either devel or a debugger and seeing what is in $profile at that point. The path to the value might not be the same for that field as for the other. Alternately, get the Entity module and use this technique.
Comment #5
System Lord CreditAttribution: System Lord commentedI got this code to display location (city and state), but I'm still getting the error below.
ERROR
My hope is someone will see this and have the "ah-ha" moment I've been waiting for and explain how I can fix this.
These are lines 78 and 79:
print drupal_render(field_view_field('profile2', $profile['profile_name'], 'field_kld_myage', 'value'));
print drupal_render(field_view_field('profile2', $profile['profile_name'], 'field_stnrd_location', 'value'));
Comment #6
System Lord CreditAttribution: System Lord commentedI also do not need the labels displayed. Any ideas how to not show them? See image.
Comment #7
jay.lee.bio CreditAttribution: jay.lee.bio commentedSystem Lord, I had a similar issue regarding #5 after upgrading to PHP 7.0.2 and the following link helped me solve my problem (look at the answer by saru1683): https://www.digitalocean.com/community/questions/strict-warning-only-var...
So try something like this:
$render_age = drupal_render(field_view_field('profile2', $profile['profile_name'], 'field_kld_myage', 'value'));
print $render_age;
$render_location = drupal_render(field_view_field('profile2', $profile['profile_name'], 'field_stnrd_location', 'value'));
print $render_location;
And for #6, a temporary solution might be to just use CSS to hide the labels:
.label_age, .label_location { display: none; }
P.S. If your solution solves my problem at #3 (I'm quite tied up at the moment), I'll provide an update accordingly.
Comment #8
jay.lee.bio CreditAttribution: jay.lee.bio commentedSystem Lord, I actually got everything working on my website! :D
1) Ignore my incorrect code at #7. Use the following version instead:
2) In my case using your code, I got errors when I went to other users' profile pages that didn't have their location fields filled in. So after playing around with and mashing up both #3 & #5, I came up with the following that seems to work 100%:
3) I was right about using CSS to hide the labels.
Comment #9
System Lord CreditAttribution: System Lord commentedThank you for the quick response. I did this and still get the same results and error.
I don't know php well, but I can understand what saru1683 is pointing out. I just don't know how to make it work.
Comment #10
System Lord CreditAttribution: System Lord commentedI just seen your #8. Let me try
Comment #11
jay.lee.bio CreditAttribution: jay.lee.bio commentedWell, you sure did a hell of a good job on #5 for someone who doesn't know PHP well. :P
I took a quick look at #9 and noticed that it's actually using #7 (it looks like we both posted almost at the same time). Make sure to use #8 and let me know if it still doesn't take care of your issues. :)
Comment #12
System Lord CreditAttribution: System Lord commentedNice! #8(2) worked! No errors!
I also did this to include both "age" and "city" but is it the correct way?
Comment #13
jay.lee.bio CreditAttribution: jay.lee.bio commentedHmmm, #12 looks confusing. The last part also looks like it's writing over itself so that the age will show up but not the location. I'm not the best developer myself, but I think the following will work better:
Comment #14
System Lord CreditAttribution: System Lord commented#13 works great! Thank you, wwwjaylee for all your help!
Comment #15
jay.lee.bio CreditAttribution: jay.lee.bio commentedNo no no, thank you for getting the toughest part working. I just got lucky finishing it up, and I'm still surprised it actually works. :D
Comment #16
System Lord CreditAttribution: System Lord commentedLet's leave this open for others to review. I'm glad it works, but I still wonder if it's the best way. The three loads seems excessive "User, Account, Profile". I don't really know, tho. Just looks odd.
Comment #17
System Lord CreditAttribution: System Lord commentedHere's what I finally did with it and it's exactly what I wanted. And, it's all in author_pane.tpl.php. No custom block or custom View.
Comment #18
jay.lee.bio CreditAttribution: jay.lee.bio commentedPer #16, I'm changing the status to "Needs review". I'm also changing it to "Feature request", since that's what it looks to me.
Comment #19
MichelleThis is a support request from almost 4 years ago. It's great that other people are getting help from it but I don't see how this is a feature request since and it doesn't need review because there's no patch nor code that's even close to something that could be added to the module. If someone wants to make a patch for location and/or profile2 integration they should go in separate issues. Also keep in mind that they would need to be proper integrations, not code shoved in the template. Also, I'm hesitant to add more integrations at this point as they are difficult to maintain and keep in sync with the integrated modules. Location, in fact, was removed due to a security issue years ago because they changed something on their end. At this point, I'd rather see it end up as a documentation page than hardcode the integration into the module itself.
Comment #20
jay.lee.bio CreditAttribution: jay.lee.bio commentedMichelle, fair enough. But do you have a link to the security issue regarding Location? Its home page seems fine to me at the moment.
Comment #21
MichelleAs I said, it was years ago. And it wasn't a security release of Location; it was a security release of AP due to Location changing something on their end and causing the integration to be insecure. This was an ongoing frustration for me for many years because I never intended these integrations be hosted in AP itself but ended up having to because I couldn't get cooperation from the other module authors. https://www.drupal.org/node/1271388
Comment #22
System Lord CreditAttribution: System Lord commentedI can successfully use this..
instead of this...
Comment #23
jay.lee.bio CreditAttribution: jay.lee.bio commentedWith #22, can you try going to other users' profile pages that did NOT have their location fields filled in and see if it still works? Also, does $uid eventually get used somewhere? It looks like it's just sitting there doing nothing right now.
Comment #24
System Lord CreditAttribution: System Lord commentedHmm. Well, I just removed that line $user = user_load(arg(1)); and it still works. So, even better!
I won't have any users without their location filled in. I use "complete profile" which forces my users to complete the location fields before their account can be created.