Hi,

I'm a little confused here. Do I alter the user-profile.tpl.php and add the fields from content_profile or do we alter the node (content-profile-display-view.tpl.php)?

The reason is currently when you click on the username anywhere on the site, it takes you through to users/* , but should it not be going through to the node 'profile' which is my content_profile?

If it should go through to the node, how do I redirect the visitor to the node page and not the user/* page?

Personally I prefer the node 'profile' and not the users/* page as it drops all the extra information such as 'Member for ..', etc. which I would like only the author (user) to see, and not the visitors to their profile.

Hope this is kind of clear .. and look forward to any reply, and thank you.

Lilian

CommentFileSizeAuthor
#3 de.gif42.23 KBbombo
#3 de2.gif39.14 KBbombo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bombo’s picture

I have a small number of users on my site and solved the problem manually until there will be an implementation in the module itself:

You can enter an "url-alias" in the user-management-area when using content_profile. Just enter user/1 (user/[uid]) there and it will redirect all sorts of references (in comments and blogs and so on) to that user onto your nice self-made profile-page and not to the default userprofile-page.

Andreas

Liliplanet’s picture

Thank you Andreas for your reply. That sounds perfect! but do not see where I can add a url-alias in the admin/user/settings.

Have over 14 000 users, so will not be able to do them individually. Please would you tell me where you found the user-alias?

Look forward to hearing from you.
Lilian

bombo’s picture

FileSize
39.14 KB
42.23 KB

I have a german translation, so i do not know what the fields are named in english. Anyways, when u edit the userdata in usermanagement section, there is a second tab beside the normal form, it is called the name you give the content type "profile" that is created, when u install the module:
user/[userid]/edit/profile. See screenshot.
In that form you find the Url-Alias. But u might find that only, if you have selected "readable url" (might be called that in your system) here: admin/settings/clean-urls.
Hope it helps. But 14000 users is too much...

U can see if you are able to manage url-aliases, if you see anything here: admin/build/path. That is where my system lists all aliases i have created in the userforms. See screenshot. So you can redirect all urls "user/*" to the corresponding "node/*". Would be great if one could find a way to make that automatically.
Sort of:
"find reference to created node type "profile" in user-data and create url-alias to node for this specific user automatically". Because the "content_profile"-module must somehow have stored a link to the correct node. Otherwise you could not edit the extended userdata when u edit a user. Don't know how to find that reference...

bombo’s picture

maybe this is a way:
for all users do
sql: select nid from node where uid='$userid' and type='profile' - gives you the nodeid of the profile-node of a user with $userid in the table "node".

then if one finds a way to automatically set the corresponding urlaliases...
sql: insert into url_alias src='node/$nid', dst='user/$uid'

incorrect sql-syntax, but that might be a way to do it.
Andreas

ximo’s picture

Maybe my approach could be useful for you? It's not stable, so I wouldn't recommend putting it on a live site, but I have a site of my own which needs this functionality, so I'd like to see it production ready relatively soon.

#356759: Tighter integration between profile nodes and user pages

Liliplanet’s picture

Hi,

Thank you for the responses. Perhaps this is a solution to add to the content profile tpl, but change it to point to the node? This is what I'm doing currently and it works, but points to the user/ and not the profile page.

<?php
// We don't ever want to go to the usernode itself. Always redirect to the user page.
drupal_goto("user/$node->uid", NULL, NULL, 301)
?>

Perhaps anyone knows how we can change that to the correct path?

Or we actually hack the user.module directly so that the path redirects ... maybe?

Look forward to your reply.
Lilian

mateb’s picture

itaine’s picture

#6 is a clean simple solution, works like a charm. This should be added to the Read Me/Documentation. Good looking out Liliplanet

arilikeairy’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta3

How did you do it? I don't have a content-profile-display-view.tpl.php or the equivalent. Where would it be? Is that the only line in it?

Thanks!

Liliplanet’s picture

Copy the content-profile-display-view.tpl.php from the content_profile module to your theme folder. Then you can edit it.

Agogo’s picture

I've been searching for some less hack of a way to do this but all my findings were none succesfull mainly because I use panels. No templates in the world seemed like a good idea and I dont like the idea of redirects anywhere but have to have the functionality some way! Anyway, I thought of sharing my little snippet for those banging their head against the keyboard. It mich help someone with the thinking process at least. This is the code I used in template.php:

function theme_preprocess_page(&$variables) {
  global $user;
  if (arg(0) == 'user' && is_numeric(arg(1))) {
    $loggeduserid = $user->uid;
    $vieweduserid = arg(1);
    if ($loggeduserid != $vieweduserid) {
      $node_profile = content_profile_load(profile, $vieweduserid);
      if ($node_profile->nid) $path = 'node/'.$node_profile->nid;
      else $path = 'user/'.$vieweduserid;
      drupal_goto($path, NULL, NULL, 301);
    }
  }
}

It simply checks whether youre trying to view your own user page or someone elses - if youre not trying to get to your own one it looks for the node-id of the content profile for the user you want to check out and then redirects you to that node. Works well with Pathauto as well since drupals arg() function checks the "real" arguments used - not the clean and dandy url youre seeing in the browser.

Ehm. Yeah. GL.

You might wanna check out these threads as well:
#276545: Have username link to profile rather than regular userpage by default
#236467: Integrate profile with user/edit
#356759: Tighter integration between profile nodes and user pages
#355760: Useful function.

mjs2020’s picture

Thanks Agogo, your snippet was really useful but I noticed a small problem: if the user does not have a content profile then the drupal_goto() function creates an infinte redirection loop.
I modified the function as follows and if the content profile does not exist it will show the user page.

function phptemplate_preprocess_page(&$vars) {
  global $user;
  if (arg(0) == 'user' && is_numeric(arg(1))) {
    $loggeduserid = $user->uid;
    $vieweduserid = arg(1);
    if ($loggeduserid != $vieweduserid) {
      $node_profile = content_profile_load(profile, $vieweduserid);
      if ($node_profile) {
      	$path = 'node/'.$node_profile->nid;
      	drupal_goto($path, NULL, NULL, 301);  //avoid rerunning this
      }
    }
  }
}

If you are using a theme developed by someone else (e.g. garland) check in template.php if there is already a function phptemplate_preprocess_page(&$vars) function.
ciao!

dugh’s picture

Yeah basically the module doesn't really work and is not actively worked on. See this:
http://drupal.org/node/276545
and the 200 other open issues for this module.

Just create a user-profile.tpl.php file in your theme folder instead. Use the devel module to inspect the $account and $profile variables.

Agogo’s picture

Yeah, I noticed that. I was thinking "Now why isnt the site loading all of a sudden?"
Thanks for posting the fix for me. May I blame insomnia?

doublejosh’s picture

Title: Link to node or user? in content_profile » Useful function.

Took me a while to find this super useful function content_profile_load($content_type, $uid).

I've used it in views argument PHP code to grab the content profile node nid for use in node_references from other thinngs to the profile.

$theArtist= content_profile_load('profile', arg(1));
return $theArtist->nid;
TKS’s picture

Or if you'd like to do the reverse -- IE, make sure one always goes to the actual user page, and never to the user-profile node, the following seems to do the trick:

function phptemplate_preprocess_page(&$vars) {
// Ensure that any stray links to profile nodes go to the actual user profile
   if (isset($vars['node']) &&  ($vars['node']->type == 'profile')) {
      $path = 'user/'.$vars['node']->uid;
      drupal_goto($path, NULL, NULL, 301);  //avoid rerunning this
      }
}

Since we have a lot of user-reference fields on our site, making sure people always go to the user page was key.

Bilmar’s picture

subscribing