By jamiegotluckies on
Hi ladies & gentlemen,
I'm trying to customize a node--TYPE.tpl.php template, and I am wondering how I can print out a custom user profile field in it.
Basically, I have a user profile field called 'field_occupation', where a user enters his/her occupation. Then inside this content type, that is submitted by users, I want a line that prints out the author's username and his/her occupation.
I googled and searched Drupal.org for some answers, but I only found code snippets for Drupal 6 and they don't seem to work for me (in Drupal 7).
I hope someone can help me out here, that would be very kind. Thanks!
Comments
I hate to do this, but, Bump!
I hate to do this, but, Bump!
Needed to do something similar today...
If you use the function: user_load($user->uid) then print_r the resulting object you will see how to access the info you need.
http://api.drupal.org/api/drupal/modules--user--user.module/function/user_load/7 for a better example!! (Read the comments...)
Hope that is helpful.
Mark
Thanks, Mark, for the reply.
Thanks, Mark, for the reply.
See, the thing is, that still only prints the user information of the user currently viewing or logged in the site. What I want to simply do is, say I'm visiting the profile page of Jane, I want to include some information that is going to say, for example, "About Jane". While I do understand that something like,
<?php print render($user_profile); ?>in user-profile.tpl.php prints out Jane's profile picture, I just can't seem to figure out how to simply print her username. I almost feel a little dumb at how I can't seem to execute such a simple function.
Did you figure it out?
I'm trying to do something very similar and can't figure it out either.
Sharon
Ditto
I am trying to figure out the same thing. I cannot believe that there is no info about this.
Similar problem - use new Profile field in Blog content type
Hi, I think I have a similar problem to you. I've created a new field called "field_job_title" for the native "People/User" content type.
I'd love to get hold of this field to use in my Blog Post content type node, "node--blog.tpl.php".
I can already print out the username by "print $name;". I wonder if there's any code, or preprocessing, that would allow me to create a new variable of "$job_title"?
Any ideas? Thanks.
You may want to use
You may want to use field_get_items as suggested above. Below is placed inside preprocess_node:
love, light n laughter
Thanks , work perfect.
Thanks , work perfect.
Hello! Great Thanks for the
Hello! Great Thanks for the code, it works good!
I use this code for printing author fields in comments:
Everithing is good save the field 'field_user_biz_dir' is of type term reference and there's nothing printing on a page. Could You help me? please?
Skype: kaztur.ru
Phone: +7 917 871 09 85
thanks, works perfect
thanks, works perfect
These snippets worked for me...
For author profile info on the node:
And for author info in comments:
mordaga, Great thanks for
mordaga, Great thanks for Your code!
It works good for fields with types as text or number, but it doesn't work with "term reference" type field - there's nothing shows. It shows only "By " text
Skype: kaztur.ru
Phone: +7 917 871 09 85
I'm trying to customize a
I'm trying to customize a node--TYPE.tpl.php template, and I am wondering how I can print out a custom user profile field in it.
Basically, I have a user profile field called 'field_profile_photo', where a user enters his/her profile photo, I want a line that prints out the profile photo.
I have two content types is an article and the other profile, I want to print the photo of the profile of a user in my article
I hope someone can help me out here, that would be very kind. Thanks!
I'm using Taxonomy term
I'm using Taxonomy term fields for Job title, items of interest etc. and I can only retrieve term id, not the term name