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.
API page: http://api.drupal.org/api/drupal/modules--user--user-profile.tpl.php
Describe the problem you have found:
We cannot use $content array for our fields display. $content works for all other template files. Rather, we need to use $user_profile. And so, if we are trying to display a field with a machine name 'field_cool', we would try and render it this way:
<?php
render($user_profile['field_cool']);
?>
Comment | File | Size | Author |
---|---|---|---|
#11 | user_profile-1123092-11.patch | 1.28 KB | michaellenahan |
#8 | user_profile-1123092-8.patch | 1.28 KB | michaellenahan |
#6 | user_profile-1123092-6.patch | 749 bytes | michaellenahan |
#5 | user_profile-1123092-5.patch | 1018 bytes | michaellenahan |
Comments
Comment #1
jhodgdonI don't understand what the documentation problem is here that you are trying to report?
Comment #2
varunarora CreditAttribution: varunarora commentedThe documentation says:
Use render($user_profile) to print all profile items, or print a subset such as render($content['field_example'])
This needs to be:
Use render($user_profile) to print all profile items, or print a subset such as render($user_profile['field_example'])
right?
Comment #3
jhodgdonThanks for the clarification!
I think that whole first paragraph probably needs to be rewritten.
Comment #4
LinL CreditAttribution: LinL commentedWorking on this at Docs sprint & plan to finish today.
Comment #5
michaellenahan CreditAttribution: michaellenahan commentedhere's the patch.
Comment #6
michaellenahan CreditAttribution: michaellenahan commentedSorry. Ignore the last patch please, here it is again. I'm new! Just learned about this today from the wonderful jhodgdon at DrupalCon London.
Comment #7
jhodgdonThanks for your contribution -- Looks good! However, the revised line is longer than 80 characters, so it needs to be rewrapped.
Comment #8
michaellenahan CreditAttribution: michaellenahan commentedHi there, here's the patch again.
Comment #9
jhodgdonSetting to Needs Review so that the test bot will test the patch (which in this case means just making sure it's formatted correctly and applies).
Comment #10
jhodgdonOne small mistake: "which" always needs a comma before it:
I realize that this was from the original, not a result of the patch, but if you could fix it that would be nice!
Also, $user_profile['user_picture'] will fit on the 80-character line wrapping, by my editor's count.
Thanks!
Comment #11
michaellenahan CreditAttribution: michaellenahan commentedThanks, jhodgton. Here's the patch again.
Comment #12
jhodgdonsetting to needs review so the test bot will launch. :)
Comment #13
jhodgdonWhenever you upload a patch, please set the status to "needs review", which alerts both human and bots that the patch needs to be tested and reviewed. :)
Anyway, this patch looks fine to me (as long as the bot agrees). 7.x/8.x please...
Comment #14
catchCommitted to 8.x, moving to 7.x for webchick.
Comment #15
webchickCommitted and pushed to 7.x. Thanks! :)