Hello,

I'm looking for days to find a way to generate node urls like mysite.org/real-user-name/title-of-the-node ...
I use a a cck content type as a nodeprofile in wich users can set their real-name.
This real-name value is used like a charm by pathauto to create user's blog url with the token [userprofile-field_profile_public_name-raw]. And it works perfectly.

But I can't find a way to do the same for Node paths..

In the template.php file, I use some php to replace the default user-name by the value of the nodeprofile field "field_profile_public_name", and it works very good with the Blogger module : the blogger list print the real-username, so I thought Token would do the same if I use [author-name-raw] but no ! It get the default username...

here is what I use in template.php :

function phptemplate_username($object) {
  // *** Replace username of user everywhere with user's full name.
  if (!empty($object->uid)) {
    // Load nodeprofile
    $nodeprofile = node_load(array('type' => 'userprofile', 'uid' => $object->uid));
    if ($nodeprofile) {
      // Get realname of user.
      $name = $nodeprofile->field_profile_public_name[0]['value'];
    }
    else {
      // Nodeprofile does not exist.
      $name = $object->name;
    }
    if (user_access('access content')){
         $output = check_plain($name);
    }
	return $output;
  }
  else if (!empty($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') .')';
    return $output;
  }
  else {
    $output = variable_get('anonymous', 'Anonymous');
    return $output;
  }
}

From that, is there a way to force Token to use the nodeprofile-field value as the user-name ?

I hope I'm clear in my description :)

Thx

Comments

dave reid’s picture

Status: Active » Closed (duplicate)