Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created September 22, 2009 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msonnabaum/191474 to your computer and use it in GitHub Desktop.
Save msonnabaum/191474 to your computer and use it in GitHub Desktop.
<?php
/**
* Implementation of hook_ctools_context_convert_list().
*/
function misc_ctools_context_convert_list($plugin, &$converters) {
if ($plugin['name'] == 'node') {
$converters = $converters + array('field_firstname' => t('First Name'), 'field_lastname' => t('Last Name'));
}
return $converters;
}
/**
* Implementation of hook_ctools_context_converter_alter().
*/
function misc_ctools_context_converter_alter($context, $converter, &$value) {
// Make sure we have a node to extract fields data from.
if ($context->type != 'node' || empty($context->data)) {
return;
}
$node = $context->data;
$value = $node->{$converter}[0]['value'];
return $value;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment