Posted by liliplanet on March 2, 2008 at 11:34am
Hi,
Hope this message finds you very well.
I would like to have company information below press releases (content type = 'article'). In my node.tpl I have
<?php
print $node->field_company[0]['value']
?>node.tpl is currently as follows:
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
<?php if ($page == 0): ?>
<?php print $picture ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<div class="meta">
<?php if ($submitted): ?>
<span class="submitted"><?php print $submitted ?></span>
<?php endif; ?>
<?php if ($terms): ?>
<span class="terms"><?php print $terms ?></span>
<?php endif;?>
</div>
<div class="content">
<?php print $content ?>
</div>
<?php if ($page == 1): ?>
<?php
// Set up some variables to make the code easier to read without the confusion of which user is which.
$loggedinuser = $GLOBALS['user'];
$profileuser = user_load(array('uid' => $node->uid));?>
<?php print theme("user_picture",$profileuser); ?><?php print $node->field_company[0]['value'] ?>
<div><?php if ($links) { print $links; }?></div><?endif;?>
</div>Please, how can I insert nodeprofile information on another content type (not profile) and not to duplicate on the profile pages?
Most appreciate any help and thank you.
Lilian

Comments
update
Got the part where I created node-article.php, but still have:
<?php// Set up some variables to make the code easier to read without the confusion of which user is which.
$loggedinuser = $GLOBALS['user'];
$profileuser = user_load(array('uid' => $node->uid));?>
<?php print theme("user_picture",$profileuser); ?><div><?php print $node->field_company[0]['value'] ?></div>
<div><?php if ($links) { print $links; }?></div><?endif;?>
</div>
the field_company does not show on my article content type ... presuming I have to load something else in place of = user_load ?
Would most appreciate help and thank you.
Lilian
...
The only way that's going to work is if "field_company" is on the article node type. It sounds like you need to load the nodeprofile node associated with the UID and reference that.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
Thank you Michelle
Thank you Michelle for your reply. Definitely stuck here ... please could you tell me exactly what has to go in there ..
Created node-article.php
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
<?php if ($page == 0): ?>
<?php print $picture ?>
<a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a>
<?php endif; ?>
<div class="meta">
<?php if ($submitted): ?>
<span class="submitted"><?php print $submitted ?></span>
<?php endif; ?>
<?php if ($terms): ?>
<span class="terms"><?php print $terms ?></span>
<?php endif;?>
</div>
<div class="content">
<?php print $content ?>
<?php if ($page == 1): ?>
<?php
// Set up some variables to make the code easier to read without the confusion of which user is which.
$loggedinuser = $GLOBALS['user'];
$profileuser = user_load(array('uid' => $node->uid));?>
<?php print theme("user_picture",$profileuser); ?><?php print $node->field_company[0]['value'] ?>
<div><?php if ($links) { print $links; }?></div><?endif;?>
</div>
just not having any joy here (nothing shows up) and would most appreciate your help.
Lilian
...
<?php
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('NODEPROFILETYPETOLOAD', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_company[0]['value']
?>
NODEPROFILETYPETOLOAD should be changed to the machine name of the node type you are wanting to load. ('uprofile' or whatever)
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
wow Michelle!
wow Michelle, thank you so much! works beautifully.
If you have another moment please ... how do I add 2 fields instead of repeating the code as I have done ...
<?php
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('platinum', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_companyname[0]['value']
?><?php
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('platinum', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_introduction[0]['value']
?>
This is wonderful .. thank you Michelle.
Lilian
oops one more question please
Michelle, sorry just one more thing ...
I would like a link from the code (or just below) to go to to the users profile with something like 'read more about 'company'...'
Is that possible please ..?
Lilian
Link
Thanks for bumping it, dougzilla. I missed this question...
The link would be
<?phpprint l('read more about ' . $nodeprofilenode->field_company[0]['value'],'user/' . $nodeprofilenode->uid)
?>
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
Thank you Michelle
I found this via the google. Thank you ever so much. This is exactly what I wanted to accomplish.
Thank you Michelle!
You have taught me so much ... thank you. Now that whole section is complete with your help. Most most appreciated.
Lilian
No problem :)
Glad to help.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
load content profile for the author of the node ..
Oops Michelle, I've moved onto content profile for 6.x ..
with the previous code for nodeprofile:
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('platinum', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_companyname[0]['value']
?><?php
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('platinum', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_introduction[0]['value']
<?php endif; ?>
please how can I change it to load content profile?
would so much appreciate your help one more time, and again thank you so much!
Lilian
Not sure
I think nodeprofile_load needs to change to contentprofile_load but I'm not sure. You could always ask in the content profile issue queue.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
hi,
hi,
bumping this because i have a question which is very related to this issue.
for instance, the code posted by michelle:
// Load the nodeprofile node for the user that is the author of the current node
$nodeprofilenode = nodeprofile_load('platinum', $node->uid);
// Print the company field from the nodeprofile node
print $nodeprofilenode->field_companyname[0]['value']
what i'd like to achieve: i'd like to show a nodeprofile cck field in the topic & comment nodes of the forum.
and i have 5 different content types as nodeprofiles. is it possible to just get that field value based on the user id ?
in stead of loading a specific content type ? or get the content_type according to the uid ?
just wanting to avoid making 5 vars to get the all the possible values from each nodeprofile because you don't know what nodeprofile to query
any help would be appreciated. thanx
as a temp solution i put the
as a temp solution i put the code in a for loop, and all my content types which i use as profiles in an array..
this is an example for the comments, for topics of course use $node->uid in stead of $comment->uid
$profileArray = array("content_type1", "content_type2", "content_type3", "content_type4", "content_type5", "content_type6");
$len = count($profileArray);
for ($i = 0;$i<$len;++$i){
$nodeprofilenode = nodeprofile_load($profileArray[$i], $comment->uid);
$currCompany = $nodeprofilenode->field_member_current_company[0]['value'];
print "<span class=\"currCompany\"><b>".$currCompany."</b></span>";
}