I am having the toughest time figuring this out. I don't know why everything else was so much easier but it was.

Here is what my user-profile should look like in the end...

https://docs.google.com/file/d/0B-eKT0Z_vxfHRnBRT254Z1NPZ0k/edit

Just so you can get a perspective on what I need to do. I'm not just showing and hiding certain info, I'm looking to make a custom structure and really drill down to the pieces I need.

What I'm having trouble doing is figuring out how to extract basic stuff. Like the username of the person whos page you're viewing. Their specific status stream, their user-picture (which I have that) and links to edit the account and such (not shown here because I forgot to add them to photoshop).

I know I can call everything at once with $user_profile but I need to just drill down to those specific things. I've tried the devel_themer and I guess I just don't understand how to do it. Ideally I'd like to see all the variables in the $user_profile array so I know how to call those things.

I guess I'm just expecting things to be something like "print render($user_profile['user_name']);" and the same for the edit account buttons and the status stream.

Any help with this wold be greatly appreciated because I've been all over the internet and can't find any help on this subject.

Comments

rommelxcastro’s picture

did you tied any module?

MaTaX’s picture

got any suggestions? I would prefer not to use a module because I really want to have total control over the html structure and how things are displayed and not just what items are displayed and stuff like that.

Madapple’s picture

I am having trouble with this myself.

I finally figured out how to call specific profile fields - only to have it now display only the info for the current user not the profile they want to see...

MaTaX’s picture

having the same issues, I'm working through them now, I used print_r($user_profile); to print out the contents of that array so I can see what's in it but I'm having a hard time drilling down to the info I need.

I'm not sure I totally understand how to extract info from a multidimensional array. I think I'm gonna jump into the core mentoring next time it's up and ask someone there how to do it.

keith.mifsud.borg’s picture

Hi Matax, I am doing something similar and you have no idea how many problems I am facing ebcause I'm trying to use a custom module but for some reason the variables do not seem to be passed using the template_preprocess (Drupal 6)

However, in Drupal 6 to do what you need to do you can use:

print $account->profile_first_name;

If you need the profile template to check if the user is the signed in user you would need to type a small function like:

function user_profile_current_user($thisUser){

global $user;
$thisUser = '';

if ($user == $user->uid)
$thisUser = 1;

else if ($user != $user->uid)
$thisUser = 0;
}

Then in your profile template you can create a function to print certain profile information based on the value of $thisUser.

To print things like:

First name type:
print $account->profile_first_name;

Picture: (depends on which module you are using if any)
print $account->content['Photo']['profile_photo']['#value'];

You may need to add this at the top:
profile_load_profile($account);

Hope this helps :)

MaTaX’s picture

the

<?php profile_load_profile($account); ?>

is that drupal 7? And if so do I need to use that before I can start accessing certain info?

Keep in mind that I'm not trying to access the currently logged in users info. I'm trying to style the user-profile page that shows for everyone. Meaning if I'm logged in as MaTaX and go to keith.mifsud.borg's profile it will be styled and layout just like MaTaX's profile, but it will show keiths information.

In order to do that I know that I need to user $user_profile, but I'm not sure where in that array are things like the username and how to print specific fields.

keith.mifsud.borg’s picture

Hi Guys,

sorry I didn't have notifications of your replies.

In my current case I wanted to create a custom module with several functions that alter the user-profile.tpl.php

My requirements was 1) to create a function that checks if the user viewing the profile is the global $user.
2) if the user is the $user then show certain blocks such as edit profile etc...
3) if the user is not the $user then show the profile as external profile
4) if the user is $user and is of certain role then show more blocks.
5) if the user is not $user and is viewing a profile of certain roles then show different blocks.

As you can see this was quite complex especially when you put in mind that the data being displayed is not only profile data but a lot more such as menu block, friends, friends doing this and that etc...

It is pointless and confusing to explain all I did but in brief I have created a custom module with several functions. The main one is the preprocess function. This way you can pass any variables to the user-profile page from your functions. However, I did not need to pass any $account variables because Drupal already passes them by default to the user-profile.tpl.php.

If you are having problems displaying $account or $profile data then ensure you are using 'user-profile.tpl.php' if you are not using this file with the exact name then you will need to pass the $account and $profile arrays yourself through the preprocess function.

Sorry if this is confusing. Feel free to ask me a specific question and I will be glad if I can help.

Madapple’s picture

turned out that using the core profile module using $user gave the current user's profile
when I changed it to $account it gave the profile information for the OTHER user...

so instead of $user->profile_name
it should be $account->profile_name

MaTaX’s picture

Am I doing this wrong because it's not working for me...

<?php print render($account->profile_name); ?>

Madapple’s picture

I am using <?php print $account->profile_name ?>