By Yucom on
Hi guys,
as the title indicates, I am unable to print single fields in the user-profile.tpl.php. I tried many different things, but nothing happens. The tpl has been recognized, as I am able to see custom text, etc. I can print all fields with a value in it via:
<div class="profile"<?php print $attributes; ?>>
<?php print render($user_profile); ?>
</div>But if I try to print a single field nothing happens. I tried:
<?php
print check_plain($user->profile_job);
?><?php
print $profile['field_job'][$lang][0]['value']
?><?php
print check_plain($user->field_job);
?><?php
print render($content['field_job']);
?>And I am sure I tried a few other things. The field does have a value, an it shows up in the full print mentioned above.
What am I doing wrong here? How am I able to print single fields?
Thanks for your help in advance!
Comments
_
Try installing and enabling the devel module, then copy user-profile.tpl.php to your theme folder and edit it so that it reads
That will show you what the data actually looks like...
Thanks so far Pete. I did
Thanks so far Pete.
I did what you said and it appears that the field I tried to print is available. Here's what it says:
I am not good with PHP, but as far as I can say, shouldn't the code from the first post work in any way? :|
_
I guess you'd need to do
render($user_profile['field_job']);Thanks for your help again
Thanks for your help again Pete. Sadly it didn't work. I am not sure what's the problem, as it is described in the api: http://api.drupal.org/api/drupal/modules--user--user-profile.tpl.php/7/s...
We today tried this:
And it said no. But the field isn't empty, as it is printed when I print them all. I really don't get it. :|
Here's a screen of what Krumo says: http://www.sternengarde.de/images/array.jpg
Okay, I solved it, and it was
Okay,
I solved it, and it was a hard lesson to learn! It took me about 8 hours to find a solution. Many thanks to Pete for his participation.
This is how you have to print single fields in your profile:
Thanks again and good night (it's 11 o'clock pm here),
Yucom
Hi Yucom, It does not work in
Hi Yucom,
It does not work in D7. Also, use-profile.tpl.php should be use_profile.tpl.php, right?
Can you help me this:
http://drupal.org/node/1108926
Thanks
It's not use_profile.tpl.php,
It's not use_profile.tpl.php, but user-profile.tpl.php.
Also I have to correct myself a little bit. This version is more correct:
And yes, it's working. I am using it right now. :)
The aboce codes does not work
The aboce codes does not work for me. Also, user-profile.tpl.php does not work for profile 2.
This is the code I got to
This is the code I got to work for me:
<?php print render($user_profile['field_user_lastname']['#items']['0']['value']);?>