Commit bdac50aa authored by jurgenhaas's avatar jurgenhaas

Include support for computed fields

parent 33786876
......@@ -12,7 +12,7 @@ function colorbox_field_formatter_field_formatter_info() {
return array(
'colorbox_field_formatter_linked' => array(
'label' => t('Colorbox link'),
'field types' => array('text'),
'field types' => array('text', 'computed'),
'settings' => array(
'colorbox_field_formatter_style' => 'colorbox-load',
'colorbox_field_formatter_link_type' => 'content',
......@@ -21,6 +21,7 @@ function colorbox_field_formatter_field_formatter_info() {
'colorbox_field_formatter_height' => '500',
'colorbox_field_formatter_iframe' => 0,
'colorbox_field_formatter_anchor' => '',
'colorbox_field_formatter_class' => '',
),
),
);
......@@ -90,6 +91,11 @@ function colorbox_field_formatter_field_formatter_settings_form($field, $instanc
'#type' => 'textfield',
'#default_value' => $settings['colorbox_field_formatter_anchor'],
);
$element['colorbox_field_formatter_class'] = array(
'#title' => t('Class'),
'#type' => 'textfield',
'#default_value' => $settings['colorbox_field_formatter_class'],
);
return $element;
}
......@@ -112,7 +118,14 @@ function colorbox_field_formatter_field_formatter_settings_summary($field, $inst
*/
function colorbox_field_formatter_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$output = isset($items[0]) ? $items[0]['safe_value'] : '';
if (isset($items[0])) {
if (isset($items[0]['safe_value'])) {
$output = $items[0]['safe_value'];
}
else if (isset($items[0]['value'])) {
$output = $items[0]['value'];
}
}
$element = array();
if (!empty($output)) {
......@@ -139,6 +152,9 @@ function colorbox_field_formatter_field_formatter_view($entity_type, $entity, $f
if (!empty($settings['colorbox_field_formatter_anchor'])) {
$options['query']['fragment'] = $settings['colorbox_field_formatter_anchor'];
}
if (!empty($settings['colorbox_field_formatter_class'])) {
$options['attributes']['class'] = array_merge($options['attributes']['class'], explode(' ', $settings['colorbox_field_formatter_class']));
}
$output = l($output, $uri['path'], $options);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment