Completely lost

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

Hi there!
I´ve been searching the forums for a while, and I´m sincerely lost about this issue.

I came to realize that there´s NO WAY to add taxonomy terms to the simple, yet easy, core module "profile".

So, I´ve installed the nodeprofile module. It needs the nodefamily to run, and it suggests you to install the usernode module.
I´ve done all that, and I´ve readed the readme files of all of them.

And yet, I´m clueless about how to replace the profile with all this confusing stuff. I´ve installed three modules already to replace one.
Everyone seems to be using them very happily, so... I´m missing something here.

I´ve created a node "profile1" with flexinode (I´m using 4.7), and wanted that node to be used by nodeprofile as a profile.
Then I related the "usernode" type of content as a child to "profile1", using nodefamily. I don´t really know why or whatfor I´ve done that anyway...

And, I´m stuck there.

I´m wondering:

Why should I need the "usernode" module for?
With all this modules, how can I replace the original profile with all this stuff?
Can I create different profile tupes with all this? HOW?

I´m sorry if I sound silly, maybe it´s pretty easy to do this, but I didn´t get it yet... maybe you could help me out... at least showing me a path to follow :-)

Thanks!!

Rosamunda

Comments

some changes needed to template.php

zzJames's picture

in the theme folder you are using, for example bluemarine, you insert a file 'template.php' in which you put two functions to override the normal links that users click to see their (or others) profile.

the functions are

<?php
/<strong>
* Catch
the theme_username function and link to the usernode instead of linking to the userpage
*/

function
phptemplate_username(&$object) {

  if (
$object->uid && $object->name) {
   
// Shorten the name when it is too long or it will break many tables.
   
if (drupal_strlen($object->name) > 20) {
     
$name = drupal_substr($object->name, 0, 15) .'...';
    }
    else {
     
$name = $object->name;
    }

    if (
user_access('access content') && module_exist('usernode')) {
     
$nid = usernode_get_node_id($object);
     
$output = l($name, 'node/'. $nid, array('title' => t('View user details.')));
    }
    else {
     
$output = check_plain($name);
    }
  }
  else if (
$object->name) {
   
// Sometimes modules display content composed by people who are
    // not registered members of the site (e.g. mailing list or news
    // aggregator modules). This clause enables modules to display
    // the true author of the content.
   
if ($object->homepage) {
     
$output = l($object->name, $object->homepage);
    }
    else {
     
$output = check_plain($object->name);
    }

   
$output .= ' ('. t('not verified') .')';
  }
  else {
   
$output = variable_get('anonymous', 'Anonymous');
  }

  return
$output;
}

/</
strong>
* Catch
the theme_user_picture function and link to the usernode instead of linking to the userpage
*/

function
phptemplate_user_picture(&$account) {
  if (
variable_get('user_pictures', 0)) {
    if (
$account->picture && file_exists($account->picture)) {
     
$picture = file_create_url($account->picture);
    }
    else if (
variable_get('user_picture_default', '')) {
     
$picture = variable_get('user_picture_default', '');
    }

    if (isset(
$picture)) {
     
$alt = t('%user\'s picture', array('%user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
     
$picture = theme('image', $picture, $alt, $alt, '', false);
      if (!empty(
$account->uid) && user_access('access content') && module_exist('usernode')) {
       
$nid = usernode_get_node_id($account);
       
$picture = l($picture, "node/$nid", array('title' => t('View user details.')), NULL, NULL, FALSE, TRUE);
      }

      return
"<div class=\"picture\">$picture</div>";
    }
  }
}
?>

Now you will need to have the 'nodeprofile' module installed and activated. What this does is give you the option to make a nodefamily (so you need the nodefamily module installed and active too). With nodeprofile module, the usernode is the 'papa' node in the family. You can add children to the papa node by using 'administer/settings/content types the click configure' and scroll down and check the 'nodeprofile' check box.

I have found it most useful to use the content creation module (module called CCK) to create a custom type of node - in my case 'biography' type, and then after creating this node type,Th go to administer/settings/content types - you will see your new custom content node type listed and click configure and check the 'nodeprofile' checkbox. (see documentation for CCK, it is fairly easy to do)

This still does not display your new node when a username is clicked (to view profile) - in order to make this happen you must create a custom template file for the usernode in your theme folder. You need to create a text file named 'node-usernode.tpl.php' and save this into your theme folder (e.g. bluemarine) including the code

<?php
$children
= nodefamily_relation_load($nid);
        print
node_view($children[0]);
  
?>

this makes the child node appear whenever the usernode is viewed. You can add more nodes to the family (by selecting 'nodeprofile' checkbox, and make them appear by using

<?php
$children
= nodefamily_relation_load($nid);
        print
node_view($children[0]);
print
node_view($children[1]);

  
?>

(sorry I have a meeting now, but will finish off how to create profiles using pageroute later)

James

p.s. this is off the top of my head so please correct me if you spot a mistake

using pageroute to 'do the whole family'

zzJames's picture

if you have added several child nodes to the usernode (using nodeprofile option) you will want the user to be able to fill in each of the nodes sequentially (probably)

first download and install 'Automatic Nodetitles' because it makes no sense to have the user fill in a title for the 'child nodes' that make up the profile.
use the page at
administer » settings » content types

to flag up which nodes you don't need the user to enter titles into.

Then set up a pageroute (with the pageroute and pageroute ui module) that goes between the edit pages of each of the nodes in the profile family.

This is fairly straightforward and the instructions on the form are pretty clear. Email again if you have more questions.

ok. hope that helps

James

THANK YOU FOR YOUR HELP GUYS!!!!!!

Rosamunda's picture

The whole explanation, and the link to that article... both terrific!!!!!
Now I must say that I´m not that lost, hehehe....
In fact, I´ve followed these instructions and... voilá!!!!!
I´ve new and bright profiles!!!

Thank to you!

Rosamunda
(Gee... I love this group already :-)

BTW... correct me if I´m

Rosamunda's picture

BTW... correct me if I´m wrong, but... there´s no 5.0 version yet, isn´t it?
(Anyway, I´m using 4.7 :)

Yes, 5.x versions are available

koorneef's picture

Just check the project pages @ Drupal, eg.: http://drupal.org/project/usernode

print Hello World!

geddon's picture

Thank you James for your guidance. I followed your instructions and -- using the limit of my php coding knowledge -- am able to view a list of members that have "Hello World" printed on their profiles. The node children are defined and I can see a clear space where the children are meant to display, but no content is actually visible:

http://www.fellowsite.org/?q=members

I'll continue to review the steps as Rosemunda has had luck with it.

If anybody knows a step I missed please let me know!

function module_exist() should be module_exists()

koorneef's picture

At least in Drupal 5.1 the function module_exist() should be module_exists() otherwise you get an PHP error

nodeprofile README

fago's picture

just follow the README of the nodeprofile module step for step..

Can someone tell me how to pull the nodeprofile data

bfbryan1811's picture

into the usernode in a customized fashion? I have decided to not user the core user profile page in favor of usernode. As a result I'd like to pull data from the users table & my CCK defined nodeprofile table as well as role info. I have my node-usernode.tpl.php file and coded for data pulled from the users table but I am struggling to figure out how to pull user's role info and user's nodeprofile data.

thanks in advance

nodefamily

fago's picture

load further data using the nodefamily relations between the usernode and the profile nodes. read the nodefamily README for some help on this.

You can access the user data, by doing an $account = user_load(array('uid' => $uid));

I have the node family set up such that

bfbryan1811's picture

Usernode is the parent and Contact Info (new content type) is the child. I lost you in how to pull the data into the user node via the node-usernode.tpl.php file. When I add print_r($user) to my theme page i get back the following array info at the bottom of the usernode page:

[content_test_profile] => Array ( [nid] => [vid] => [created] => [type] => content_test_profile [changed] => [field_first_name] => Array ( [0] => Array ( [value] => gary ) ) [field_last_name] => Array ( [0] => Array ( [value] => bisbe ) ) [field_firm_name] => Array ( [0] => Array ( [value] => leh ) ) [field_work_telephone_number] => Array ( [0] => Array ( [value] => 212-833-0493 ) ) ) [submit] => Create new account [form_id] => user_register [role] => 7 [form_token] => 31a31377ddf619415b95060531dc86aa [roles] => Array ( [2] => authenticated user [8] => Sell Side Analyst ) )

How do I pull the values? I am new to php. Go easy.

?

fago's picture

$account = user_load(array('uid' => $uid));

I have tried that using

bfbryan1811's picture

<?php
print $account->field_last_name;
?>
but see only a blanks space. When I try
<?php
print $account->roles;
?>
to pull the role i get "Array".

To print the first and last

jpsalter's picture

To print the first and last name with a space in the middle use this:

<?php
print $account['field_first_name'][0]['value'] . ' ' . $account['field_last_name'][0]['value'];
?>

Thanks, I tried this but nothing comes up.

bfbryan1811's picture

Could there be something I am forgeting?

Profiles as nodes

Group organizers

Group notifications

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

Hot content this week