Skip to content

Instantly share code, notes, and snippets.

@pvhee
Created November 5, 2013 20:58
Show Gist options
  • Select an option

  • Save pvhee/7326203 to your computer and use it in GitHub Desktop.

Select an option

Save pvhee/7326203 to your computer and use it in GitHub Desktop.
Extend Scald data views supports to display arrays for nested values
diff --git a/includes/scald_views_handler_field_data.inc b/includes/scald_views_handler_field_data.inc
index 936f700..583ff42 100644
--- a/includes/scald_views_handler_field_data.inc
+++ b/includes/scald_views_handler_field_data.inc
@@ -44,7 +44,13 @@ class scald_views_handler_field_data extends views_handler_field {
$data = unserialize($values->{$this->field_alias});
$content = NULL;
if (!empty($data[$this->options['data_key']])) {
- $output = (string) $data[$this->options['data_key']];
+
+ if (is_array($data[$this->options['data_key']])) {
+ $output = var_export($data[$this->options['data_key']], TRUE);
+ } else {
+ $output = (string) $data[$this->options['data_key']];
+ }
+
$content = array(
'#markup' => $this->options['plain'] ? check_plain($output) : $output,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment