Content profile can't handle translated profiles
ShutterFreak - May 13, 2009 - 09:54
| Project: | Content Profile |
| Version: | 6.x-1.0-beta3 |
| Component: | Base module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
I am setting up a multilingual Intranet server based on Drupal 6.
When I allow the "Profile" content type to be translated, then the Content Profile module shows me a "create" link whenever I click on a user name to see their profile, even though the user already has a profile.
Disabling content translation for the Profile content type functions correctly.

#1
There is a bug in content_profile.module:content_profile_load() that I haven't quite worked out yet. I will post again soon with a fix.
#2
#3
#4
#5
Changing status
#6
hi, the link for the file does nto link to anything.
Chris
#7
@ wad
Please attach the correct files.
#8
Sorry for the bad posts. I was getting disconnected from d.o. due to too many mysql connections.
This is only a partial fix that will stop the behaviour mentioned by the o.p. The real fix should allow several content_profile content items to be valid depending on what language they are viewed in. For example, I should be able to create a profile in Spanish and English with a fallback to the site's default language (English) if there is no Spanish profile created yet. I think the real bug there is that cp content is not being saved with a language but I could be wrong.
#9
#10
>I think the real bug there is that cp content is not being saved with a language but I could be wrong.
Content profile doesn't change the usual node-behaviour here, so this should work fine.
As of now, the profile is displayed in the currently activated language on the user page. I'm not sure if it should fall-back to the default language, if there is no profile in the current one. If you think so, roll a patch..
However content_profile_load() should always work right, with the above patch it would return the wrong language profile afterwards even if the language is specified explicitly.
#11
Good point.
I do not know which module should be in charge of selecting the appropriate language version of multilingual content. Each language version is a separate nid. IIRC there's a distinct table keeping track of which nids link to the same "meta node".
Maybe it's just a matter of implementing one or more i18n hooks in the content_profile module?
#12
@fago: there is definitely a problem with translation handling. I will try to explain the situation without the above patch.
In a test site, I have these content items and users, where
/admin/settings/language/configureI have Language negotiation: Path prefix with language fallback/admin/settings/language/i18n/configureI have Content selection mode: Current language and language neutral.Title Type Author Status Language
================================================================
Test 2 User Profile test2 published Language neutral
Test 1 User Profile test1 published English
UID Username Status Roles
==================================
4 test2 active artist
3 test1 active artist
1 admin active
When I visit
/users/test1, I see the Test 1 User node contentWhen I visit
/users/test2, I see the default (system) profile content with a link to 'Create the user's Profile.'When I visit
/es/users/test1, I see the default (system) profile content with a link to 'Create the user's Profile.' Same applies for test2.As test1 user (UID=3), when I visit
/es/user/3/edit/profile, I get a new form to create a new profile. If I change the node's language to Spanish and save it I get a new node. Switching languages shows the relevant content from each node correctly. However, I do not see a link to Translate the node I am editing in either language.As test2 user (UID=4), when I visit
/es/user/4/edit/profile, I get a new form to create a new profile. If I leave the node's language as 'Language neutral' and save it, it throws the error:This user has already a content profile of this type. You can only create one profile per user.The message should say "You can only create one profile per user per language" which is kinda confusing.Using the above patch, I at least get 'Language neutral' content to display but there is more to be done for correct handling.
#13
subscribing.
#14
sub
#15
subscribing
#16
Also interested in a solution... Subscribing.
#17
Susbcribing. Any idea when will you be able to apply something to a release?
#18
another related issue #368510: Translate node types
if you only need to fix the title translation you have two choices (exclusive, just one or the other)
368510#comment-2061346
368510#comment-2061360
#19
Susbcribing
#20
I think if a node type has been checked to be a content profile, it shouldn't be shown under "Create content". It should only appear in the edition of "My account".
And, if the site has translations enabled, and the user the permissions to translate, In that tab inside my account, the user should be able to translate the content profile.
In node limit number (#586064-22: Node Limit Number for Drupal 6 - FEATURES REQUEST) @jdwfly gave me a code for another thing, that allows to check if the new node is a translation, maybe that can be used here:
if (isset($node->translation_source)) {return FALSE;
}
return TRUE;
#21
I'm using the new node limit number module for drupal 6 and created a rule saying that a user can create one node of content profile unless the new node it's a translation, and it worked.
So, it should only be necessary to remove the option to create a node type under "create content" and to create a translate link in the Account. So, after the user has a profile created, he can translate it. Is there any way you can include this?
And of course, in the profile page, when I change language, the content should be shown according to the language, as now is not doing that. It always shows the original node.
#22
in my case, when viewing a a user page, content_profile_load is called, $lang isn't set.
so adding a language-retrieval and a fallback, if language isn't available works as a quickfix.
<?php
function content_profile_load($type, $uid, $lang = '') {
static $cache = array();
global $language ;
$lang = $language->language;
if (!isset($cache[$type][$uid][$lang])) {
$cache[$type][$uid][$lang] = FALSE;
$params = array('type' => $type, 'uid' => $uid);
if ($node = node_load($lang ? $params + array('language' => $lang) : $params)) {
$cache[$type][$uid][$lang] = $node->nid;
}
else {
// current language not available so try without
$node = node_load($params);
$cache[$type][$uid][$lang] = $node->nid;
}
return $node;
}
return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
}
?>
though, it would be interesting, why the $lang variable isn't set...