/**
* Plugin to provide an relationship handler for node from user
*/
function advanced_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' => 'advanced_profile_panels_context',
'settings form' => 'advanced_profile_panels_settings_form',
);
return $args;
}
/**
* Return a new context based on an existing context
*/
function advanced_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 advanced_profile_panels_settings_form($conf) {
$options = content_profile_get_types('names');
dsm($options);
'#type' => 'select',
'#title' =>
t('Relationship type'),
'#options' => $options,
'#default_value' => $conf['type']
);
return $form;
}
Comments
Post new comment