I took the relationship code I wrote for nodeprofile and updated it to work with content profile. It's only had minimal testing but seems to be working fine so far. If you could get this commited soon, I'd appreciate it. I'm trying to get something usable going for APK in D6 and the less patching users have to do to other modules the better.


/**
 * Plugin to provide an relationship handler for node from user
 */
function content_profile_panels_relationships() {
  $args['node_from_user'] = array(
    'title' => t("Profile node from user"),
    'keyword' => 'profile_node',
    'description' => t('Adds a profile node from user context'),
    'required context' => new panels_required_context(t('User'), 'user'),
    'context' => 'content_profile_panels_context',
    'settings form' => 'content_profile_panels_settings_form',
  );
  return $args;
}

/**
 * Return a new context based on an existing context
 */
function content_profile_panels_context($context = NULL, $conf) {
  // If unset it wants a generic, unfilled context, which is just NULL
  if (empty($context->data)) {
    return panels_context_create_empty('node', NULL);
  }

  if (isset($context->data->uid)) {
    // Load the node for the requested type
    $uid = $context->data->uid;
    $content_profile_node = content_profile_load($conf['type'], $uid);
   
    // Send it to panels
    return panels_context_create('node', $content_profile_node);
  } 
  else {
    return panels_context_create_empty('node', NULL);
  }   
}

/**
 * Settings form for the relationship
 */
function content_profile_panels_settings_form($conf) {
  $options = content_profile_get_types('names');

  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Relationship type'),
    '#options' => $options,
    '#default_value' => $conf['type']
  );

  return $form;
}

Thanks,

Michelle

Comments

michelle’s picture

Any thoughts on this? I know it's the holidays, but I'm really trying to push APK for D6 out and this is a major stumbling block...

Michelle

somenoise’s picture

I will love to see this commited :)

fago’s picture

Status: Needs review » Fixed

Have you seen this issue? http://drupal.org/node/322782

As the code looks like being the same, I've just committed it. Please test..

michelle’s picture

No, I hadn't until you pinged me on IRC. Luckily I didn't spend too much time on it. Doh!

I'll give it a whirl in a bit if the kids stay behaving.

Michelle

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

1kenthomas’s picture

Status: Closed (fixed) » Active

Wait, is this not committed?

michelle’s picture

Status: Active » Fixed

Yes, this was committed nearly 2 years ago.

Michelle

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.