In content_profile.theme_vars.inc the function get_variables caches and returns the variables, but if two (or more) content types are being used as content profiles, the function will only return the first variables.

For example:

$myprofile = $content_profile->get_variables('profile');
$mynetworkingprofile = $content_profile->get_variables('networkingprofile');

What will be returned in the profile type, but networkingprofile will be ignored since the function already has something cached.

I'm not exactly sure how something like this can be resolved but I thought I'd throw it out there as a feature request (or to find out how I'm not doing something right...).

I resolved it by using my own preprocess function in order to create a new class instance:

function MYTHEME_preprocess_user_profile(&$variables){
  module_load_include('inc', 'content_profile', 'content_profile.theme_vars');
  foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) {
    if (isset($variables[$name])) {
      $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name];
      $variables['content_profilenetworking'] = new content_profile_theme_variables($uid);
      break;
    }
  }
}

The code was borrowed from content_profile.module. Seems kind of inelegant, but it works.

Comments

marcp’s picture

Status: Active » Closed (duplicate)