How do I create a menu link to a user's profile node please?

CommentFileSizeAuthor
#7 331821.patch1.8 KBGeorge2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blackdog’s picture

Status: Active » Postponed (maintainer needs more info)

A content profile node gets a node id just like any other node, so you can link to that.

fehin’s picture

I don't think that's what the person was asking.

I'm also looking for a way to do this.
I want users to be able to click on a member's name in my forum and it takes them to that member's profile. I used '/user' and it takes the anyone who clicks on the name to their own "my account" page. What link can I use for this? Thanks.

VM’s picture

correct /user isn't enough as that dynamically grabs the UID of the user who is doing the clicking of the link.

You may need some php for this in your theme.

arilikeairy’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-beta3

Any suggestions on the PHP?

This seems like a pretty big issue to me...isn't the whole point of user profiles to let other users view them? I've messed around with this for a few hours now and I can't figure anything out working with an unhacked module.

jeellis2’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-beta2

I'm also looking for a way to do this, any hints regarding the "php for this in my theme"

It is a fairly basic need to be able to view other profiles on the site, correct?

andreiashu’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-beta3

I think solving #236467: Integrate profile with user/edit can also solve this issue. Takeover profile functionality would replace the users page with the its Content Profile node so if you profile a link like node/[uid] (where [uid] is the user's id) we could accomplish what you need here.

George2’s picture

FileSize
1.8 KB

very dirty hack patched on beta3 to add an edit-profile link. it adds a menu item at the path edit-profile which just redirects to the real profile editing url

i've not been following all the content_profile issues, but is the idea to allow more than one profile content type per user? if so, then avoid this patch :)

fehin’s picture

I placed this line

print $name;

in my node-forum.tpl.php and it gives me a link to the user's profile. You can place it in content types like comment.

superdorx’s picture

I'm waiting for the release of this module in 6. I believe will be the easiest method to add menu items.
http://drupal.org/project/menu_token

malc_b’s picture

If you add token and automatic aliases then you can give profile nodes an automatic alias of /profile/[author-uid]. The do something similar for the menu.

superdorx’s picture

Thank you for that. Can you please explain this in more detail? Has anyone successfully done this?

superdorx’s picture

New solution as of today! Check out new added feature to "me aliases" module here http://drupal.org/node/450460. Use global tokens as provided by the http://drupal.org/project/token module, including [user-name].

malc_b’s picture

Install token http://drupal.org/project/token and automated aliases http://drupal.org/project/pathauto . Then go to /admin/build/path/pathauto and under the setting for the user profile node content type insert

/user/view/[author-uid]

So /user/view/3 will show you user 3 content profile page and so on. The author of a content profile is always the user that profile refers to.

That works. I haven't tried a menu yet but I'd guess /user/view/[uid] may work and if not a bit of php would sort it.

13rac1’s picture

me aliases cannot link to URL aliases, such as what would be created with profile/[author-id] by pathauto. It can only link to the edit view of a content profile because that is a real(specified by module) path.

Is there any other way to do this? It is fine if I have to use me aliases. Can we get a redirect at user/[uid]/profile/profile_name/view to the actual profile? For now, I think the quick option for me (since I am not using the profile module), is to write a simple module to redirect /profile to /profile/[uid].

Later, if not done, I will write a patch to do this. Right now I am looking at deadline, so that is not an option.

jonhattan’s picture

I do this in my theme to add a link to edit the profile node in

function mytheme_user_profile($account, $fields = array()) {
  $node = content_profile_load('profile', $account->uid);
  $content .= '<div id='edit-profile'>'.l(t('Edit profile'), 'node/'.$node->nid.'/edit', array('query' => 'destination='.url('user/'.$account->uid))).'</div>';
}
Patroclas’s picture

It's nearly two years on from my first post on this and there is no useful solution.

It's easy to set up a link for a user to edit their own CP node. The path is just "node/add/[content-type]" where [content-type] is the type atached to the content profile. If the node already exists, it's shown in edit mode.

There is still a real need to be able to view a user's CP node without linking to their profile. Although this is a great module, and my site would not be possible without it, I still find the various tabs in the Profile page to be a nuisance and have never found a satisfactory way of organising them. It would also be great to be able to send a link to the user's CP node in a message from their contact form (instead of lnking to user/[uid]) and to be able to set a menu item for users to view their own node without going to their profile or the edit screen.

cbearhoney’s picture

jonhattan: Where do you put this theme function - in your template.php?

z3cka’s picture

I was in a situation where I wanted to keep the links to the user pages intact and be able to link to a users profile from a node that was created by that user. I was able to do this by preprocessing a variable like this:
template.php

<?php 
function YOURTHEME_preprocess_node ($variables) {
// grab the author's uid
$nodeAuthor = user_load(array('uid' => $variables['node']->uid));
// grab the profile's nid
$node = content_profile_load('profile', $nodeAuthor->uid);
// print link to profile node as alias
$variables['profile_alias'] = l(t($nodeAuthor->field_name_first),drupal_get_path_alias('node/'.$node->nid));
?>

This assumes you are using a CCK field for First name (field_name_first), but this text can be substituted with static link text or whatever. Also, the Content Profile content type is profile.

Then, in node.tpl.php (or node-NODETYPE.tpl.php) print this new variable like this:

<?php
<div class="profile-alias"><?php print $profile_alias; ?></div>
?>

And style.

rayvan’s picture

I just needed to add this to a block, so this is the PHP I used:

global $user;
$node = content_profile_load('profile', $user->uid);

// If the profile node has been created by user, return View Profile link that goes to node
if ($node) {
  $output.= l('View Profile', 'node/' . $node->nid);
  return $output;
}

Sort of inefficient but a suitable short-term measure until the larger problem is addressed.