I am fairly new to Drupal . While I am fairly able to get results with php sytax , like many it seems I am struggling with drupal . Anyone who can help with this?
I have members on my site . I used the content profile module in favour of the std profile module .
I have all my user field created as a content type profile. All is well and good it seems to be working and registration is working also .
I am using the zeropoint theme and have created the user-profile.tpl.php file and that is overiding correctly .
~~ Here is the rub ~~
In order to make my profile pages look pretty , of course I want to change the layout .
How do I access the content profile fields . If I write a print_r($user) or a print_r($profile ) I seem to get usable arrays of info that include an array name "content profile"
Very simple ask is how do I write each field into that template file ..$user_profile presents all the fields but how do I access each field independantly.
can someone give me some syntax examples . Should be sooo simple
eg. I have a field called "real_name" and another called "subtrade".
how would I write ~~ $real_name does $subtrade for a living ( easy in php ... three day task in drupal )
Comments
FOUND IT Wahoooo. But why was it nowhere in the Drupal site
Go to this link to read a good explanation and practical example .
http://geeksandgod.com/forums/dynamic-website-forums/all-about-drupal/wh...
just in case this link disappears I am posting the guts of it.
Hi,
I've created a few custom user profile fields using the Content Profile module.
In my theme file I can view the new fields using the following code:
$var = $content_profile->get_variables('user_profile');
print_r($var);
Now, I could access each field like this:
print $var['field_first_name'][0]['value'];
But is this the "correct" way of getting the field value? Is there a standard/best practice way to do this?
Thanks,
Steve
July 22, 2009 - 7:52pm
BishopBooyah
BishopBooyah's picture
Joined: 10/18/2008
User offline. Last seen 3 weeks 2 days ago.
That's one way to do it, but
That's one way to do it, but in D6 one of the preferred ways is to use a preprocess node and define new variables.
In your template.php file,
function MYTHEME_preprocess_page(&$variables)
{
// add the taxonomy term description to the variables
$variables['mynewvar'] = $['node']->field_cckcontenttype_field[0]['view'];
If (logic){
$variables['mylogicvar'] = "do your logic in here rather than in your tpl.php file";
}
}
Then in your tpl.php you can just print out those new variables you defined:
print $mynewvar;
print $mylogicvar;
Ideally you don't want logic in your tpl files.
.
If you want simple, use Page Manager / Panels and you can point and click instead of trying to write code in your theme. :)
Michelle