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

wad - June 6, 2009 - 18:38

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

wad - June 6, 2009 - 19:37
AttachmentSize
cp_translated_profiles.patch 602 bytes

#3

wad - June 6, 2009 - 19:40

#4

wad - June 6, 2009 - 19:42

#5

dddave - June 6, 2009 - 23:45
Status:active» needs review

Changing status

#6

SocialNicheGuru - June 8, 2009 - 22:32

hi, the link for the file does nto link to anything.

Chris

#7

dddave - June 10, 2009 - 14:08
Status:needs review» needs work

@ wad

Please attach the correct files.

#8

wad - June 11, 2009 - 07:39

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.

AttachmentSize
cp_translated_profiles.patch 602 bytes

#9

dddave - June 11, 2009 - 09:15
Status:needs work» needs review

#10

fago - June 11, 2009 - 15:21
Status:needs review» needs work

>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

ShutterFreak - June 13, 2009 - 12:26

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

wad - June 16, 2009 - 19:04

@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

  • Profile is a content type with these options checked:
    • Multilingual Support: Enabled, with translation
    • Content Profile Use this content type as a content profile for users
  • I have both English (default) and Spanish languages enabled with these options checked:
    • at /admin/settings/language/configure I have Language negotiation: Path prefix with language fallback
    • at /admin/settings/language/i18n/configure I have Content selection mode: Current language and language neutral.
  • Anonymous and Authenticated users have permissions to access both content and user profiles.
  • Authenticated users also have permissions to create, delete and edit their own profile content and translate content.

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 content

When 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

asak - June 26, 2009 - 19:25

subscribing.

#14

YesCT - July 3, 2009 - 03:21

sub

#15

Shai - July 3, 2009 - 05:35

subscribing

#16

Jolidog - July 8, 2009 - 23:25

Also interested in a solution... Subscribing.

#17

mairav - September 16, 2009 - 15:50

Susbcribing. Any idea when will you be able to apply something to a release?

#18

arhak - September 19, 2009 - 19:49

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

blueblade - September 23, 2009 - 00:37

Susbcribing

#20

mairav - October 5, 2009 - 18:53

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

mairav - October 5, 2009 - 20:20

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

dasjo - November 30, 2009 - 09:41

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...

 
 

Drupal is a registered trademark of Dries Buytaert.