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.
By dalegrebey on
I think the title about sums it up.
For Drupal 7, I am specifically wanting to print the Author of the Node's Profile information. For example, if I add I biography field to my list of profile questions, I want to display this field on a node.
The core distinction here being that, I do not want to display the VISITOR'S profile information, but the AUTHOR'S information.
Thanks.
Comments
Here we go... Using the
Here we go... Using the user_load and passing it the User ID (Author) of the node turned out to be the trick. Copy this into your node--event.tpl.php and adjust the fields accordingly. I prefer to use a specific Content Type so that the Author Information isn't being parsed for pages that do not need to have it displayed.
This would for example: print the User's role (Administrator in this case) and then their Biography field.
Hope that helps.
Thanks! But ....
Hello ! Thanks for your contribution, but would
$node_author = user_load($node->uid);
be helpful for me to do the following :I want to create a block containing node's and node author's informations (like the node rate, the last edit, the author name and picture, his points, etc.). But this block would be located into another region than the node content currently is attributed to (reffering to Bartik, the block would be in sidebar-second when the content is in content...).
Thks for your help !
I would presume that you
I would presume that you could use this as a starting point. Obviously the Author's Name, Picture, When the post was Created and Changed are already available to you. Regarding points and rating, I'm not entirely too sure at present.
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
Helpful tips
Thank you for sharing, Helpful
Not sure but you can try this
- Mittal Patel
http://www.MittalPatel.co.in
http://www.TriCoreITSolutions.com
Can I use this to get the
Can I use this to get the real name of the blogger?
I want to replace user name with Author name ie. chutchi with Chris Hutchins,
I tried some of the above code but it failed for me :(
Provide more info
Have you created the fields using profile2 module? What is the machine name of your profile (like in my case it's 'blogger_profile') and what's the machine name of your profile field (like in my case it's 'field_full_name')?
- Mittal Patel
http://www.MittalPatel.co.in
http://www.TriCoreITSolutions.com
Hi Mittalpatel,Background
Hi Mittalpatel,
Background info: I am using the blog module and Drupal 7. This is a multi-user site. profile2 module... No I have not looked into this. But I will investigate. How would this help?
I would like each post to list the authors name as if an article but the author name is not available as a variable. I also tried altering the preprocess function but that didn't work for me...
I altered the blog output with node--blog.tpl.php so that it now
some thing like
but I would like to notify this so that it reads the author name
However, how do I get the name of the Author?
At the very least I would like to capitalize the user name (Bingham) which I attempted to do with the PHP function ucwords() but this did not work... for some reason.
While I have your attention, I would also like to modify the link of the username to a custom author page...
I tried something like this but apparently this does not work..
node--blog--19.tpl.php (author uid)
node--blog--bingham.tpl.php
My URL alias is setup as
http://mysite.com/blog/bingham/post-title-here
Any suggestions greatly appreciated.
Curtis
Use profile2 module
Hello Curtis,
I think you should check out the profile2 module as it will allow you to create more fields for the user. You can create First Name and Last Name fields and then use those values as described in my previous comment.
If you just want to make the first letter capital of the username then it can be done with CSS too. Something like
- Mittal Patel
http://www.MittalPatel.co.in
http://www.TriCoreITSolutions.com
This worked for me!!!
Thanks mittalpatel! That solution worked perfectly for me and ended several days of trial and error!
Heres another way
Heres another way thats much easier: Enable the tokens filter module then use the following in your tpl.php:
<?php print token_replace('[node:title] Info Maintainer: <a href="../user/[node:author:uid]/contact" title="Contact [node:author]">[node:author]</a>', array('node' => $node));
Obviously this is to paste a contact link but you can use whatever tokens you like.
Inside a view of node
Inside a view of node teasers, I'm trying to print Authors' telephone number from their profile2 field.
However, on my site only the "Business" account holders can hold a business_profile profile type.
I'm using this code:
This code inside my node.tpl.php works only for those nodes that were created by "Business" account holders. For all other nodes created by normal accounts, it fills the screenwith these errors:
Can someone PLEASE help? If the user has a business_profile and if that profile has a field_telephone, it should be printed.
_
You don't do any if-then test to see if the user has the field so when it tries to print for users that don't have the field, it throws that error.
But you say you're doing this in a view of teasers though, so why not just add a relationship to the node author and add it to the view that way?
Thanks, I actually had to add
Thanks, I actually had to add 2 relationships: one for node author and then another one for the Profile,in order to retrieve that telephone field. It worked, but strangely not for every person who has a telephone field. My worry is that building it like this through Views is going to slower the pageloads when traffic starts pouring in. My other worry is that the view is an unordered list of teasers, which are themed from inside node--type.tpl.php, and itrequires a lot of messy CSS to put that field in the right place.
Is there a cleaner and faster way to do this from inside the node--type.tpl.php ? I mean, what would be the correct syntax for that kind of if-then test that you mentioned? Thanks.
_
I can't say with any certainty, but I would think a single query from views would be more efficient than doing an entire profile load. Views can also be cached.
That sounds really wrong. Just theme the view itself. Also, it sounds like your forcing views into formatting nodes which is not at all what views was meant to do. Although it can be used that way, there are better ways for format nodes.