Using "profile" fields held in nodeprofile content types?

Events happening in the community are now at Drupal community events on www.drupal.org.
jockox3's picture

I posted this in the support forums on drupal.org and then wondered if it might be better in here. It may be more suited to module development, but it's about use, I think, not development.

Anyhow, I'm probably missing something really easy, but I've done an extensive trawl of what documentation I can find and can't get any clues.

I have implemented usernode + nodeprofile (and registerprofile). On sign-up a user is presented with the user form asking for a username and email and under that the one content type I have designated as a nodeprofile. Now, this all works pretty well at the moment, but there's a lot of work for me to do theming various pages, so before I go too far down that route I want to just check - can I now reference these nodeprofile fields as if they were user fields?

For example, I want my users (an alumni assoicaiton) to be able to add little snippets of news (a CCK type) both about themselves, the default, or about another alumnus who is not registered on the site, say. And I want the titles of these news snippets to be consistent - with forename, surname, house and cohort. So I want to compute a field to create a default title, consisting of these fields from the nodeprofile content type for the user that's logged in and creating the news snippet.

Also I'd like the AuthorInfo module to pick up a computed field on the nodeprofile content type. Is that possible? If so I suspect I'm getting the "Real Name" field wrong.

Cheers,

Jock Coats

Comments

Could it be here?

jockox3's picture

I was browsing through the body/teaser templates for my content type and noticed a field available of the form "$user->content_basic_member_information['nid']"

So I guess the answer to my first question is yes, it is possible to refer to nodeprofile data as if it were profile data when you have $user available. I just need to work out how to load the $user array and refer to it in calculated fields I guess. Does that sound about right?

I haven't managed it

zzJames's picture

in my

'node-usernode.tpl.php'

I tried including the lines

global $user;
print $user[picture]

and

print $user[nid]

but nothing appears. however if I put

print_r($user)

I do see the whole array.

I may be having problems interpreting how to go from the output of print_r to the actual variable I want .....

keep going!!

The $user variable is

jpsalter's picture

The $user variable is usually returned as an object not an array. When you view print_r, you should see the word "object" or "array".

Try using $user->picture and $user->nid

Also, if $user->something is an array, then to reference an item inside it use:
$user->something['keyname']

But, if $user->something is another object, then:
$user->something->keyname

By reading the output of print_r carefully, you should be able to tell what is an array and what is an object.

Good luck,

Could you tell with an example how to add a custom field?

Rosamunda's picture

Hi there!

Please, could you tell with an example how to add a custom field?
I´m not a programmer, and I´ve tried several ways... with no luck at all :-)

Thanks for your help!!

Rosamunda

not entirely sure

zzJames's picture

depends on your needs. either create custom node with the fields you want with CCK (+ use contemplate to format output!)

or create something custom, but since you are not a programmer this might be confusing, although it is never too late to start and there are some excellent guide books, and drupal in some cases makes it easier. You would have to understand MySQL also, at least how to make a table and create, read, update and delete a record from a table.

probably having read that you'll pick CCK!! :-)

link

oh yeah

zzJames's picture

to quote homer simpson "doh!"

too much actionscripting recently methinks.

:-)

Profiles as nodes

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: