function ctools_context_node_convert in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 plugins/contexts/node.inc \ctools_context_node_convert()
Convert a context into a string.
1 call to ctools_context_node_convert()
- ctools_context_node_edit_convert in plugins/
contexts/ node_edit_form.inc - Convert a context into a string.
1 string reference to 'ctools_context_node_convert'
File
- plugins/
contexts/ node.inc, line 190 - Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.
Code
function ctools_context_node_convert($context, $type) {
switch ($type) {
case 'nid':
return $context->data->nid;
case 'vid':
return $context->data->vid;
case 'title':
return $context->data->title;
case 'uid':
return $context->data->uid;
case 'type':
return $context->data->type;
}
// Check if token.module can provide the replacement.
if (module_exists('token')) {
$values = token_get_values('node', $context->data);
$key = array_search($type, $values->tokens);
if ($key !== FALSE) {
return $values->values[$key];
}
}
}